I’m not sure where you got that syntax, but that’s not how you call procedures with node-odbc.
Here’s the docs:
https://github.com/IBM/node-odbc?tab=readme-ov-file#callprocedurecatalog-schema-name-parameters-callback
parameters?: An array of parameters to pass to the procedure. For input and input/output parameters, the JavaScript value passed in is expected to be of a type translatable to the SQL type the procedure expects. For output parameters, any JavaScript value can be passed in, and will be overwritten by the function. The number of parameters passed in must match the number of parameters expected by the procedure.
All parameters are just values, there is no need to describe what types they are.
Try this instead:
const result = await connection.callProcedure(null,
defaultSchema,
procedureName,
[
runSchema,
undefined // output parameter
]
);
From: OpenSource <opensource-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Hopkins, Matt <hopkins.matthew@xxxxxxxxxxxxxx>
Date: Tuesday, April 29, 2025 at 10:52 AM
To: opensource@xxxxxxxxxxxxxxxxxx <opensource@xxxxxxxxxxxxxxxxxx>
Subject: [EXTERNAL] [IBMiOSS] nodejs stored procedure call - Program type out of range
I’m new to Node and stored procedures, so I’m sure I’ve done something wrong,
but I keep getting an error ‘Program type out of range’. As far as I can tell
everything should line up.
This is what I am getting:
Error calling RPGLE procedure: [Error: [odbc] Error binding parameters to the
statement] {
odbcErrors: [
{
state: 'HY003',
code: 0,
message: '[unixODBC][Driver Manager]Program type out of range'
}
]
}
Here is the RPGLE procedure interface definition. It is in service program PLOC
:
Dcl-pi PlocReview;
RunLib char(10) const;
Match varchar(5000);
End-pi;
Here is the stored procedure definition:
CREATE OR REPLACE PROCEDURE MODVANTIS.PLOC_REVIEW (
IN RUNLIB CHAR(10) ,
OUT MATCH VARCHAR(5000) )
LANGUAGE RPGLE
SPECIFIC MODVANTIS.PLOC_REVIEW
NOT DETERMINISTIC
NO SQL
EXTERNAL NAME 'MODVANTIS/PLOC(PLOCREVIEW)'
PARAMETER STYLE GENERAL ;
I have tried 2 different methods to call the procedure with the same results.
try {
// Connect to the database via ODBC
const connection = await odbc.connect(connectionConfig);
const sql = `{CALL ${defaultSchema}.${procedureName}(?, ?)}`;
let outputparm = '';
const statement = await connection.createStatement();
await statement.prepare(sql);
const result = await statement.bind([
{ParamType: 'INPUT', DataType: 'CHAR', LENGTH: 10, Data:
runSchema.padEnd(10, ' ') },
{ParamType: 'OUPUT', DataType: 'VARCHAR', LENGTH: 5000, Data: outputparm }
]);
const result = await statement.execute();
Also tried:
const result = await connection.callProcedure(null, defaultSchema,
procedureName, [
{ Value: runSchema, IO: 'IN' }, // Input parameter: Run library
{ Value: '', Length: 5000, IO: 'OUT' }, // Output parameter: name
(varchar)
]);
■ Matt Hopkins ▪ IBMi Programmer Analyst
IM&T
The Penn Mutual Life Insurance Company
e. Hopkins.Matthew@xxxxxxxxxxxxxx
p. 860-298-6005 c. 410-258-8845
w. pennmutual.com ▪ gateway.pennmutual.com
This message, including any attachments, is intended only for the recipient(s)
named above. It may contain confidential and privileged information. If you have
received this communication in error, please notify the sender immediately and
destroy or delete the original message. Also, please be aware that if you are
not the intended recipient, any review, disclosure, copying, distribution or any
action or reliance based on this message is prohibited by law.
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
https://archive.midrange.com/opensource .
As an Amazon Associate we earn from qualifying purchases.