problems with odbc(informix) + c-application

problems with odbc(informix) + c-application

Post by Andrei Romazano » Thu, 21 Jun 2001 22:44:21



Hello ng,

 are there any restrictions for the length of SQL statement in
SQLExecDirect? Application falls, after SQL was extended. The current length
of SQL is about 1700 character, is called so:

 char sql_stmt[2000 ];
 int sql_length;

....
 sql_length = sizeof(sql_stmt) + 1;
 err = SQLExecDirect(pHstmt, (unsigned char *)sql_stmt, sql_length);

regards

Andrei

 
 
 

problems with odbc(informix) + c-application

Post by John Hobso » Sat, 23 Jun 2001 02:21:12


Your code should probably be either

    sql_length = strlen(sql_stmt);
    err = SQLExecDirect(pHstmt, (unsigned char *)sql_stmt, sql_length);

or

    err = SQLExecDirect(pHstmt, (unsigned char *)sql_stmt, SQL_NTS);

You need to pass the actual length of the SQL statement, not the size of the buffer.
You appear to be telling ODBC that your SQL statement is 2001 characters in length.


> Hello ng,

>  are there any restrictions for the length of SQL statement in
> SQLExecDirect? Application falls, after SQL was extended. The current length
> of SQL is about 1700 character, is called so:

>  char sql_stmt[2000 ];
>  int sql_length;

> ....
>  sql_length = sizeof(sql_stmt) + 1;
>  err = SQLExecDirect(pHstmt, (unsigned char *)sql_stmt, sql_length);

> regards

> Andrei