-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
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.
var bindvars = {
...req.body.bindvars,
res_source_id: {
type: oracledb.NUMBER,
dir: oracledb.BIND_OUT
},
res_operating_unit: {
type: oracledb.STRING,
dir: oracledb.BIND_OUT
},
res_contract_number: {
type: oracledb.STRING,
dir: oracledb.BIND_OUT
},
res_response_code: {
type: oracledb.STRING,
dir: oracledb.BIND_OUT
},
res_response_mesg: {
type: oracledb.STRING,
dir: oracledb.BIND_OUT
},
res_response_sev: {
type: oracledb.STRING,
dir: oracledb.BIND_OUT
}
};
var plsql =
`
DECLARE
P_REQUEST_TBL <Request_Table_Declaration>;
type varchar2_aat is table of varchar2(150)
INDEX BY BINARY_INTEGER;
l_asset_numbers varchar2_aat;
BEGIN
P_REQUEST_TBL(1).Contract_Number := :contract_number;
P_REQUEST_TBL(1).partial_term_flag := :partial_term_flag;
P_REQUEST_TBL(1).Quote_term_date := to_date(:quote_term_date,'YYYY-MM-DD');
P_REQUEST_TBL(1).Quote_buyout_reason := :quote_buyout_reason;
P_REQUEST_TBL(1).Late_Charges := :late_charges;
P_REQUEST_TBL(1).Processing_Fees := :processing_fees;
P_REQUEST_TBL(1).Requested_by := :requested_by;
l_asset_numbers := :asset_numbers;
for asset in 1 .. l_asset_numbers.count
loop
P_REQUEST_TBL(1).asset_number_tbl(asset).ASSET_NUMBER := l_asset_numbers(asset);
end loop;
CUSTOM_PKG.Custom_Procedure(P_REQUEST_TBL);
END;
`;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.