-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue using arrays as IN parameters #1039
Comments
Can you clarify a few things? The PL/SQL looks like it is accepting IN parameters but your bind definitions show OUT parameters? And the bind variable names don't match -- so it looks like some are missing from your definition? The only array looks to be the bind variable |
The var bindvars = {
...req.body.bindvars The request is built from a front-end form, with default values for testing bindvars: {
contract_number: '123456789',
partial_term_flag: 'N',
asset_numbers: ['ASDFQWER','UIOPVBNM'],
quote_term_date: '2019-01-30',
quote_buyout_reason: 'Other',
late_charges: '',
processing_fees: '',
requested_by: 'Jane Doe'
} |
Can you use this instead? asset_numbers: { type: oracledb.STRING, val: ['ASDFQWER', 'UIOPVBNM'] } Let me know if that works better for you. |
Interesting, I was able to get it to work by assigning the request's asset_numbers to the value of the object you sent above. bindvars.asset_numbers = {
type: oracledb.STRING,
val: bindvars.asset_numbers
} Is there a reason you can think why the scalar values do not require the object binding? |
Well, if the value is an object the code assumes you are specifying the type, value, direction, etc. in that object, but if the value is not an object, the code assumes that is the bind value itself. There are explicit checks for dates, buffers and LOB objects (which are themselves objects but can be bound directly) but not for arrays. That should probably be corrected in order to avoid this sort of issue. I'll take this as an enhancement request, then. :-) |
Thanks for the help and the explanation! I had not dealt with sending objects over yet, so I didn't run into any issues like this yet. It would be exceptionally helpful if simple-typed arrays could be passed directly in the future. |
@Savahn Node-oracledb 4.0 has been released with an enhancement for this. The release announcement is at https://blogs.oracle.com/opal/oracle-db-named-objects-and-advanced-queuing-support-new-in-node-oracledb-40 |
I'm running into an issue trying to bind an array of VARCHAR2 to a simple PL/SQL procedure using oracledb. The procedure takes a record input where one element of the record is a table of VARCHAR2. The scalar binds are working fine, and I have been using your guide for decomposing and recomposing records and tables (https://jsao.io/2017/01/plsql-record-types-and-the-node-js-driver/).
I'm trying to rebuild the table inside the PL/SQL as mentioned in the link above like this after creating a connection.
Running that gives the error: NJS-044: named JSON object is not expected in this context.
The asset_numbers variable is an array of strings being passed from the calling function (e.x. ['ASDFQWER','UIOPVBNM']).
For reference I'm running Node.js v8.12.0 on Windows 64 with oracledb version 3.1.1.
The text was updated successfully, but these errors were encountered: