node-odbc
node-odbc copied to clipboard
[BUG] Cannot call stored procedures created with a "specific" name
Describe your system
-
odbc
Package Version: 2.4.8 - unixODBC version: 2.3.9-1
- ODBC Driver: IBM i Access ODBC Driver 1.1.0.27-0
- Database Name: DB2 for i
- Database Version: IBM i 7.4
- Database OS: IBM i 7.4
- Node.js Version: v18.18.2
- Node.js OS: IBM i 7.4
Describe the bug When creating stored procedures with a "specific name" that is different than the regular name, it doesn't seem possible to call it from node-odbc. It either says the stored procedure doesn't exist or it says the number of parameters doesn't match.
Expected behavior It should work the same way as Run SQL scripts - ie it should work.
Code to Reproduce SQL to create and example output from running it:
drop procedure if exists NODEODBC.test_specific;
drop procedure if exists NODEODBC.testspec;
CREATE PROCEDURE NODEODBC.test_specific (
INOUT message varchar(128)
)
LANGUAGE SQL
SPECIFIC testspec
BEGIN
set message = 'goodbye';
return 42;
END;
call NODEODBC.test_specific('hi there');
-- output:
Return Code = 42
Output Parameter #1 (MESSAGE) = goodbye
NodeJS code example 1 and output:
import odbc from 'odbc';
let conn = await odbc.connect('DSN=*LOCAL');
let parameters = ['hi there'];
let result = await conn.callProcedure(null, 'NODEODBC', 'TEST_SPECIFIC', parameters);
console.log(result);
-- output:
node stored-proc-specific-name.js
node:internal/process/esm_loader:108
internalBinding('errors').triggerUncaughtException(
^
[Error: [odbc] CallProcedureAsyncWorker::Execute: Stored procedure 'NODEODBC.TEST_SPECIFIC' doesn't exist] {
odbcErrors: []
}
Node.js v18.18.2
NodeJS code example 2 and output:
import odbc from 'odbc';
let conn = await odbc.connect('DSN=*LOCAL');
let parameters = ['hi there'];
let result = await conn.callProcedure(null, 'NODEODBC', 'TESTSPEC', parameters);
console.log(result);
-- output:
node stored-proc-specific-name.js
node:internal/process/esm_loader:108
internalBinding('errors').triggerUncaughtException(
^
[Error: [odbc] The number of parameters the procedure expects and and the number of passed parameters is not equal] {
odbcErrors: []
}
Node.js v18.18.2
Additional context For what it's worth, Run SQL Scripts only works with the "regular" name, it doesn't allow calling the procedure with the "specific" name. This is okay because at least it's possible to run one way or the other, but with node-odbc neither works and is a problem.
I'm not sure but this may be a bug in the actual ODBC driver. Hopefully someone can confirm...
I've spoken to IBM support about this and right now they agree that it seems to be a bug in the IBM i ODBC driver. I will update this after a fix has been provided.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.