Bug #5562 SQLGetData BIGINT column problem
Submitted: 14 Sep 2004 8:01 Modified: 10 Dec 2004 12:12
Reporter: Sureshkumar Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:unixODBC 2.2.9 OS:Linux (SuSE Linux 9.1)
Assigned to: CPU Architecture:Any

[14 Sep 2004 8:01] Sureshkumar
Description:
When tried to read a value of column type of BIGINT in mysql database using unixODBC, the values happens to be always 0.

How to repeat:
1. Create a table  containing bigint colum
          mysql> create table ttt ( big_int BIGINT);
          mysql> insert into ttt values (1);
          mysql> insert into ttt values (2);
          mysql> insert into ttt values (3);

2. execute the following code snippet inside a c program after making successful connection.
               /* Connection made, now make a statement */
               SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt);
               SQLExecDirect(hStmt, "select big_int from ttt", SQL_NTS);
		long value = 0, outsize = 0;
		while (SQLFetch(hStmt) == SQL_SUCCESS) {
		       SQLGetData (hStmt, 0, SQL_BIGINT, &value, 0, &outsize);
			printf ("value %ld\n", value);
		}

3. expected results
           value 1
           value 2
           value 3
    but, the actual results currently getting is
           value 0
           value 0
           value 0
[10 Dec 2004 12:12] Harun Eren
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

Using wrong SQLGetdata() TargetType , possible are the following:

SQL_C_SBIGINT
SQL_C_UBIGINT

This is importend for conversion to C Datatypes, but requires int64 c variable. 
Also is possible to use SQL_C_LONG Datatype, to write into a 32bit "long".