Error with larger OUT Parameter
Closed this issue · 6 comments
Hi there,
i have an issues with calling an IBM i Stored Procedure which we used with the old Node.js DB Providers back in Node 6 and with idb-pconnector.
After testing many, many things I found out it it is the length of the output parameter.
What I do is:
CREATE or replace PROCEDURE SESEDI.SPTEST8 (
IN TEST CHAR(10) CCSID 1208 ,
OUT RVALUE VARCHAR(2000) CCSID 1208 )
LANGUAGE SQL
SPECIFIC SESEDI.SPTEST8
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
SET OPTION ALWBLK = *ALLREAD ,
ALWCPYDTA = *OPTIMIZE ,
COMMIT = *NONE ,
DECRESULT = (31, 31, 00) ,
DYNDFTCOL = *NO ,
DYNUSRPRF = *USER ,
SRTSEQ = *HEX
BEGIN
SET RVALUE = 'Hello World' ;
RETURN ;
END ;
This works fine when I call it this way:
const result = await connection.callProcedure('MYDSN', 'MYLIB','SPTEST8', ['12345', null]);
When I enhance the OUT Parameter to (for example) 16000 it doesn't work anymore.
In my original procedure I return 32000 as varchar.
This is a "legacy" thing which is caused by the problem that the first DB driver for Node.js (back in 2014) didn't return a result set. So I solved it this way.
Can you enhance that value easily?
Otherwise I need to change a lot of stuff or find another way.
Many thanks and have a great weekend!
Markus
Originally posted by @mlitters in #326 (comment)
Here I already posted the Logfile - I thought my problem could be the same as the one with the many parameters. Maybe their problem is not the many parameters but the buffer?!?
Ups - right now we use this on a IBM i 7.3 with Node.js 14 and 18.
Hi @mlitters,
I will see if I can recreate this issue today. Hopefully it is the same issue as #326, and we can get it solved! I will say that I tried with 75 parameters, but all of them were fairly small, so maybe you are in that it is the buffer size of all combined parameters. Like I said, I will take a peek!
@mlitters could you give it a shot with the latest package version (2.4.8)? With 2.4.7 and below I am seeing:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
IOT/Abort trap (core dumped)
But with the latest version, I am seeing the correct results. I believe @kadler 's PR here may have helped: #318
@markdirish Hi,
many thanks for the update.
This works.
Indeed I had another issue with the wrong number of Parameters. That was fixed by renaming the specific name to the same as the procedure.
Many thanks to you and @kadler
Great!