Hi,
I'm new to mySql. I've got a table with an integer field defined like
this:
    l_start_wait int(9) not null
I inserted a value into the table using mysql command line client with:
    Insert into tbl_wait_list values(12345678);

When I use mysql_fetch_row() to retrieve the column values I am
surprised to see
that mysql_fetch_lengths() returns a length of 8 rather than 4 and
row[0] seems to
point to bytes containing ascii characters "12345678" rather than being
a pointer 
to an int.

I've searched the manual and google but apart from occasional references
to blob 
data most examples seem to assume that all data is ascii.

What I'd like to be able to do is something like this: int i =
(cast)row[0];

Please tell me what I'm doing wrong - or is this a limitation?
Thanks,
Andy.

Here's my code fragment if it helps:

int checkWaitList(MYSQL *aDb)
{
        // aDb connection is already open 
        MYSQL_RES *rsResult;
        MYSQL_ROW row;
        char pszSql[256];
        int lStartTime;
        unsigned long *lengths;

        strcpy(pszSql, "SELECT l_start_wait FROM tbl_wait_list");
        mysql_query(aDb,pszSql);
        rsResult = mysql_use_result(aDb);

        if (row = mysql_fetch_row(rsResult)) {
            lengths = mysql_fetch_lengths(rsResult);
            sprintf(pszSql, ">>%d, %12.12s<<\r\n", lengths[0], row[0]); 
// Prints >>8,     12345678<<
            return -1;
        }
        else {
            return 0;
        }
}






        mysql_query(aDb,pszSql);
        rsResult = mysql_use_result(aDb);

        if (row = mysql_fetch_row(rsResult)) {
            lengths = mysql_fetch_lengths(rsResult);
            // Found a row
            tsOut("Found: " );
            tsOut("\r\n");
            //lStartTime =  *(int *)row[1];
            sprintf(pszSql, ">>%ud, %12.12s<<\r\n", lengths[0], row[0]);

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to