I'm having some varying problems with the parameter declarations with
stored procedure.  I'll start off with the simpliest case and hope that
it isn't something silly on my part.

Here are the 2 stored procedues I'm comparing:

CREATE DBPROC test1(IN num1 FIXED(1),
IN num2 FIXED(2)) AS
BEGIN
  select * from tpcw.item;
END;

CREATE DBPROC test2(IN num1 FIXED(1),
OUT num2 FIXED(2)) AS
BEGIN
  set num2 = 0;
END;


There is the (simplified) code I'm using to call each stored procedure:

        /* for test1 */

        SWORD num1 = 1;
        UDWORD num2 = 2;
        SQLAllocHandle(SQL_HANDLE_STMT, odbcc.hdbc, &odbcc.hstmt);
        SQLPrepare(odbcc.hstmt, "CALL test1(?,?)", SQL_NTS);
        SQLBindParameter(odbcc.hstmt,
            1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0,
            &num1, 0, NULL);
        rc = SQLExecute(odbcc.hstmt);
        if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
        {
            odbc_error(SQL_HANDLE_STMT, odbcc.hstmt);
            return W_ERROR;
        }
        SQLBindParameter(odbcc.hstmt,
            2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0,
            &num2, 0, NULL);
        rc = SQLExecute(odbcc.hstmt);
        if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
        {
            odbc_error(SQL_HANDLE_STMT, odbcc.hstmt);
            return W_ERROR;
        }


        /* for test2 */

        SWORD num1 = 1;
        UDWORD num2;
        SQLAllocHandle(SQL_HANDLE_STMT, odbcc.hdbc, &odbcc.hstmt);
        SQLPrepare(odbcc.hstmt, "CALL test2(?,?)", SQL_NTS);
        SQLBindParameter(odbcc.hstmt,
            1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0,
            &num1, 0, NULL);
        rc = SQLExecute(odbcc.hstmt);
        if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
        {
            odbc_error(SQL_HANDLE_STMT, odbcc.hstmt);
            return W_ERROR;
        }
        SQLBindParameter(odbcc.hstmt,
            2, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0,
            &num2, 0, NULL);
        rc = SQLExecute(odbcc.hstmt);
        if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
        {
            odbc_error(SQL_HANDLE_STMT, odbcc.hstmt);
            return W_ERROR;
        }


So test2 executes as expected, while test1 results in the following
error:

SQLSTATE 07001
[SAP AG][LIBSQLOD SO]Wrong number of parameters.

I'm a little baffled by this.  If I'm doing what I think I'm doing, I
just changed INPUT to OUTPUT for num2, and changed the stored procedure
and bind calls accordingly.

Thanks,
Mark

_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to