paulomcnally/jt400.js

Not all out parameters available on stored procedure call

Opened this issue · 2 comments

I am able to successfully call an iSeries stored procedure that has 1 in and 3 out parameters. However it seems that only parameter 3 has a value. Looking at the code I found that it only puts results into the last parameter. Commenting out the below lines returns all out parameter values:

            var result = {};
            for (i = 0; i < outputParams.length; i++) {
              // if(i == outputParams.length - 1 )
              // {
                result[outputParams[i].Index] = callStatement.getStringSync(outputParams[i].Index).trim();
              // }
            }
            self.emit('executeStoredProc', null, result);

Also, how do you call a stored procedure that has IN parameters but returns a data set result rather than OUT parameters? It calls the SP successfully but no rows are returned. Thanks!

Figured out that by using the standard database.execute command that you can a stored procedure with IN parameters and still get the full recordset back. i.e. database.execute("CALL SPNAME('IN1', 'IN2','IN3'");

Hello @random0000, I just saw this so I am sorry it took so long to reply. I believe the answer to your first post was actually fixed in #13 in December but it doesn't look like the change has been updated in npm (your solution is also better). @paulomcnally, do know if this has been updated?

Unfortunately, I don't have access to an AS400 anymore so I cannot immediately look into the other issues.