Thursday, March 4, 2010

helpful sqlglm

While trying to debug an error message from some of my programs.
I've found the sqlglm() function to be very useful and more informative than SQLCODE.
I've never been able to find SQLCODE values in any oracle pro*c documentation.

For example the following statement gives an error.

exec sql at DB_NAME select 'XE' into :o_value from t_tran;
printf("sqlcode %ld \n",SQLCODE);
sqlcode -2112

Using sqlglm( ) after each sql statement I was able to understand the error message.
buff_len=sizeof(buff);
sqlglm(buff, &buff_len, &msg_len);
printf( "SQL ERROR %s\n",buff);

SQL ERROR SQL-02112: SELECT..INTO returns too many rows

No comments:

Post a Comment