Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> SQLBindParameter(dynamic) & SQLDescribeParams

SQLBindParameter(dynamic) & SQLDescribeParams

From: Harp <hmetu_at_gmx.net>
Date: 21 Feb 2005 10:08:08 -0800
Message-ID: <1109009288.369604.136230@c13g2000cwb.googlegroups.com>


Hi!
I just want to bind the parameters dynamically and have tried the following:

#define SMALL_LEN 30
static AnsiString stmt = "{CALL test(?,?,?,?)}";//just for e.g SQLSMALLINT data_len[SMALL_LEN],data_null[SMALL_LEN]; SQLSMALLINT data[SMALL_LEN];
SQLUINTEGER parlen[SMALL_LEN];
SQLUINTEGER collen[SMALL_LEN];
SQLSMALLINT len = 30;
SQLSMALLINT numCols;
SQLCHAR colName[SMALL_LEN];
string name[] = {"firstname","familyname","address"}; //just for example

rc = SQLPrepare(hstmt, stmt.c_str(), SQL_STMT_LEN); rc = SQLNumParams(hstmt,&numCols);
if(rc == SQL_SUCCESS){
for(int i = 0; i < numCols; i++){//numCols is quite ok - 4 rc = SQLDescribeParam(hstmt, (SQLSMALLINT)i+1, &data, &parlen
, &data_len, &data_null);
if(rc == SQL_SUCCESS){
if(i != 3){
rc = SQLBindParameter(hstmt, (SQLSMALLINT)i+1, SQL_PARAM_OUTPUT,SQL_C_CHAR,SQL_C_CHAR,len,0, (void *)name.c_str(),0,&DataLen);
}

else{
rc = SQLBindParameter(hstmt,(SQLSMALLINT) i+1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_C_CHAR, SMALL_LEN,0,pSalesMan,0,&sqlnts);
}
}
}//end of for(int ...)
}

The point of interest is that of SQLDescribeParam. I just want to get the description or information about the parameters to be able to pass them to SQLBindParameter. But the SQLDescribeParam (though rc gives back 0), but the data always gives 12. How do I interpret this? What does 12 stand for? If for e.g. I call the method: SQLDescribeParam(hstmt,1,12,999,0,1), that means, the outputs are: SWORD = 12,UDWORD = 999, SWORD = 0, SWORD = 1. I was hoping to get sth. like SQL_CHAR for e.g. What is the best way to achieve this?

Thanks and regards
Harp Received on Mon Feb 21 2005 - 12:08:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US