INOUT Parameter Binding is not working properly

Issue #13 resolved
Kristopher Baehr created an issue

When calling an RPG Stored Procedure from Node.js with an in/out parameter the call does not contain the value I'm trying to pass. Changing the call parameter to input results in the value being passed correctly. The Stored Procedure is being created with "PARAMETER STYLE GENERAL."

Stored Procedure definition: CREATE OR REPLACE PROCEDURE &LIB/WORMLSTSP ( INOUT gact CHAR(2)
, IN cusr CHAR(10)

The First Node.js Stored Proc call: getAction = 'RE'; stmt.bindParam([ [getAction, connection.db.SQL_PARAM_INPUT_OUTPUT, 1], [currentUser, connection.db.SQL_PARAM_INPUT, 1], ...

Result: The first Parameter's value is received by RPG as X'F02F' The stored procedure intentionally changed the value of the getAction parameter to 'OX' during the first call.

All Subsequent calls now send in OX, even though I'm explicitly setting the getAction to 'RE' before binding.

Changing the call to this works, but I don't get the new getAction value back: getAction = 'RE'; stmt.bindParam([ [getAction, connection.db.SQL_PARAM_INPUT, 1], [currentUser, connection.db.SQL_PARAM_INPUT, 1],

Please advise.

Comments (6)

  1. Jesse G

    @xumeng, are we missing logic in the following block of code in db2stmt.cc?

          String::Utf8Value param(object->Get(0));
          if(inOutType == SQL_PARAM_INPUT && obj->spInCount < SP_PARAM_MAX) {  //It is an input parameter.
            buf = obj->spIn[obj->spInCount] = strdup(*param); //Get the parameter string value.
            obj->spInCount++;
            if(bindIndicator == 0) //CLOB
              obj->indicator[i] = paramLen = strlen(*param);
            else  if(bindIndicator == 1) {//NTS
              paramLen = 0;
              obj->indicator[i] = SQL_NTS;
            }
          }
          else if(inOutType == SQL_PARAM_OUTPUT && obj->spOutCount < SP_PARAM_MAX) {  //It is an output parameter.
            buf = obj->spOut[obj->spOutCount] = (char*)calloc(paramSize + 1, sizeof(char));
            obj->spOutCount++;
            obj->indicator[i] = paramLen = paramSize;
          }
          DEBUG("SQLBindParameter [%d] = %s \n", i + 1, buf)
          rc = SQLBindParameter(obj->stmth, i + 1, inOutType, SQL_C_CHAR, dataType, paramSize, decDigits, buf, paramLen, &obj->indicator[i]);
    
  2. mengxumx Account Deactivated

    @krisbaehr Commit f844836 fixes the 'in/out parameter missing' issue. It is still being tested. If you wish to test it early, you can compile it with gcc.

  3. mengxumx Account Deactivated

    Hello @krisbaehr , Would you verify if the issue is solved in idb-connector version 1.0.7?

  4. Kristopher Baehr reporter

    @mengxumx , I'm testing with 1.0.9 this morning and can confirm that the in/out parameter issue seems to be fixed. I've debugged the stored procedure to verify the values are going in, and coming out as expected, even after multiple calls. Thanks!

  5. Log in to comment