Bug #9784 MyODBC-3.51.11-2 SQLDescribeParam
Submitted: 9 Apr 2005 15:07 Modified: 29 Sep 2008 16:32
Reporter: Anurag Chakravarti Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:MyODBC-3.51.11-2.i586.rpm OS:Linux (suse)
Assigned to: CPU Architecture:Any

[9 Apr 2005 15:07] Anurag Chakravarti
Description:
Hi,

Am using MyODBC-3.51.11-2 to connect to MySQL.

During SQLDescribeParam I always get the following output whatever may be the column type.

Column size                  = 255
sqlDataType                 = 12
decimalDigits               = -26267
nullable                         = 2

I have been fighting over this for the past few weeks and am just not able to understand what is going on. 

I am using MySQL 5.x. The same problem is seen with MySQL 4.11

Any help would be appreciated.

Thanks
-Anurag 

How to repeat:
Somethinglike this is trivial and I must have missed out something or maybe this is a known problem with a known solution.

Please help me out on this.
[9 Apr 2005 17:07] Jorge del Conde
SQLCHAR       Statement[100];
SQLSMALLINT   NumParams, i, DataType, DecimalDigits, Nullable;
SQLUINTEGER   ParamSize;
SQLHSTMT      hstmt;

GetSQLStatement(Statement);
SQLPrepare(hstmt, Statement, SQL_NTS);

SQLNumParams(hstmt, &NumParams);
if (NumParams) {
   SQLPOINTER * PtrArray = (SQLPOINTER *) malloc(NumParams * sizeof(SQLPOINTER));
   SQLINTEGER * BufferLenArray = (SQLINTEGER *) malloc(NumParams * sizeof(SQLINTEGER));
   SQLINTEGER * LenOrIndArray = (SQLINTEGER *) malloc(NumParams * sizeof(SQLINTEGER));

   for (i = 0; i < NumParams; i++) {
   SQLDescribeParam(hstmt, i + 1, &DataType, &ParamSize, &DecimalDigits, &Nullable);
   AllocParamBuffer(DataType, ParamSize, &PtrArray[i], &BufferLenArray[i]);
   SQLBindParameter(hstmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, DataType, ParamSize,
         DecimalDigits, PtrArray[i], BufferLenArray[i],
         &LenOrIndArray[i]);
   GetParamValue(PtrArray[i], BufferLenArray[i], &LenOrIndArray[i]);
   }
}

SQLExecute(hstmt);

for (i = 0; i < NumParams; i++)
free(PtrArray[i]);
free(PtrArray);
free(BufferLenArray);
free(LenOrIndArray);
[19 Sep 2006 19:05] Bogdan Degtyariov
SQLDescribeParam always returns SQL_VARCHAR. This behavior is related to the structure of MyODBC 3.51. It is not planned to make updates in SQLDescribeParam() function. However, MyODBC 5 has this function fully implemented
[29 Oct 2006 4:31] MC Brown
No changelog entry required.
[29 Sep 2008 16:32] Andrii Nikitin
according to bug 35957 Connectors 5.1 do not have this feature implemented also