10. Understanding ODBC Connectivity : ODBC Programming : Database Procedure Execution : Database Procedures with Input Parameters
 
Share this page                  
Database Procedures with Input Parameters
Input parameters are sent to the database procedure but not returned to the application. The following example shows how input parameters are used:
SQLINTEGER retval = 500;
SQLINTEGER orind = 0;
 
SQLBindParameter( hstmt,  /* Statement handle */
    1,                    /* Parameter number */
    SQL_PARAM_INPUT,      /* It's an input parameter */
    SQL_C_LONG,           /* Source data is an integer */
    SQL_INTEGER,          /* Target column is an integer */
    0,                    /* Length not required */
    0,                    /* Precision not required */
    &inputVal,            /* The data itself */
    0,                    /* Max length not required */
    &orind1);             /* Indicator can be zero */
 
SQLExecDirect( hstmt, "{ call myDbProc ( ? ) }", SQL_NTS );
Note that the ParameterType argument for "inputVal" is now SQL_PARAM_INPUT. The parameter marker "?" is now designated as an input parameter to myDbProc by placing it within the parentheses after myDbProc.