[unixODBC-support] Retrieval of Bound Parameter Descriptor Records Problems

Roberts, George L groberts at telcordia.com
Thu Jun 29 20:48:04 BST 2006


Using unixODBC 2.2.11 on CentOS Linux with Oracle 10.2.1

 

After SQLBindParameter and SQLPrepare, I run SQLDescribeParam and it
seems to always return the DataTypePtr value of 12 (for SQL_VARCHAR) and
the other return values are bogus defaults of 999, 0, and 1,
respectively.

 

Additionally, after SQLGetStmtAttr for APD, the SQLGetDescRec and
SQLGetDescField calls always return -2 (SQL_INVALID_HANDLE).

 

Is these known problems or am I doing something wrong?  

 

================Code snippet below for problem #1:

 

SQLRETURN cliRC = SQL_SUCCESS;

SQLHANDLE hstmt; /* statement handle */

  

SQLCHAR *stmt = (SQLCHAR *)

    "DELETE FROM test WHERE test_int = ? ";

 

SQLSMALLINT parameter1 = 0;

SQLSMALLINT numParms = 0;

SQLHANDLE   hAPD; /* descriptor handles */

SQLSMALLINT myDataType;

SQLULEN     myParamSize;

SQLSMALLINT myDecimalDigits;

SQLSMALLINT myNullable;

 

cliRC = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);

DBC_HANDLE_CHECK(hdbc, cliRC);

 

cliRC = SQLBindParameter(hstmt,           //Stmt Handle

                           1,             //Parameter Number

                           SQL_PARAM_INPUT,     //Input/Output Type

                           SQL_C_SHORT,         //Value Type (C data
type)

                           SQL_SMALLINT,  //Parameter Type (SQL type)

                           0,             //column size

                           0,             //decimal digits (scale)

                           &parameter1,         //parm value pointer

                           0,             //buffer length (cbValueMax)

                           NULL);         //String Len or INdr Ptr
(cbValue)

STMT_HANDLE_CHECK(hstmt, hdbc, cliRC);

 

cliRC = SQLPrepare(hstmt, stmt, SQL_NTS);

STMT_HANDLE_CHECK(hstmt, hdbc, cliRC);

 

cliRC = SQLDescribeParam(hAPD, 1, &myDataType, &myParamSize, 

               &myDecimalDigits, &myNullable);

    printf("DescribeParam cliRC=%d\n",cliRC);

    printf("DESC_TYPE=%d (%s)\n",myDataType,DESCTYPES[myDataType]);

    printf("Parm Size=%d\n",myParamSize);

    printf("Decimal Digits=%d\n",myDecimalDigits);

    printf("Nullable=%d\n",myNullable);

 

*******  OUTPUT  *********

DescribeParam cliRC=0

DESC_TYPE=12 (SQL_VARCHAR)

Parm Size=999

Decimal Digits=0

Nullable=1

**************************

 

==================Code snippet below for problem #2:  After
SQLGetStmtAttr for APD, the SQLGetDescRec and SQLGetDescField calls
always return -2 (SQL_INVALID_HANDLE)

 

cliRC = SQLGetStmtAttr(hstmt,

                         SQL_ATTR_APP_PARAM_DESC,

                         &hAPD,

                         SQL_IS_POINTER,

                         NULL);

  printf("GetStmtAttr cliRC=%d\n",cliRC);

  STMT_HANDLE_CHECK(hstmt, hdbc, cliRC);

 

SQLCHAR     colname[200];

  SQLSMALLINT namelen;

  SQLSMALLINT type;

  SQLSMALLINT subtype;

  SQLINTEGER  width;

  SQLSMALLINT precision, scale, nullable;

cliRC = SQLGetDescRec(hAPD,

                       1,

                       colname,

                       sizeof(colname)/sizeof(CHAR),

                       &namelen,

                       &type,

                       &subtype,

                       &width,

                       &precision,

                       &scale,

                       &nullable);

  printf("GetDescRec cliRC=%d\n",cliRC);

 

SQLSMALLINT descType;

cliRC = SQLGetDescField(hAPD, //descriptor Handle

                          parmIndx,    // record Number  //ignored for
header fields/

                          SQL_DESC_TYPE, // Field Identifier

                          &descType, // pointer to Value // result

                          SQL_IS_SMALLINT, // buffer/value Length

                          NULL); //string Length // ignored 

  printf("GetDescField DESC_TYPE=%d(%s)
cliRC=%d\n",descType,DESCTYPES[descType],cliRC);

 

 

G. Lee Roberts

FCS-C4ISR-SOSCOE-Data Store

groberts at telcordia.com

732-933-2474 (work)

609-306-2352 (cell)

609-918-9307 (home)

GLeeRoberts3077 (AIM)

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20060629/bfa93a6f/attachment.html>


More information about the unixODBC-support mailing list