hmm...I was hoping it was just a missed sqlcode. I dont think you are
going to be able to determine much by the info I have. This is just
what is being logged from sqlca.sqlcode after statement:
EXEC SQL
DECLARE c1 CURSOR FOR stmt;
sprintf(logstr, "Error from DECLARE, SQLCODE %d ",
(short)sqlca.sqlcode);
the logs says:
2006.02-01.10:14:14.681992 c0v0 XDB Error from DECLARE, SQLCODE 72
Just after logging it does a: if (sqlca.sqlcode == 0){
it does not go in here so I know it is returning a non-zero sqlcode.
The logging has always been correct in the past so I have reason to
believe it is correct.
There is nothing between the EXEC, sprintf and the 'if'. logstr is
also plenty long enough.
I will have to try using the debugger on it to see if the memory space
is being overwritten by something else running or if db2 is, in fact,
sending back a 72. This is currently being run on a test machine where
there is very little running.
> EXEC SQL
> DECLARE c1 CURSOR FOR stmt;
>
> sprintf(logstr, "Error from DECLARE, SQLCODE %d ",
> (short)sqlca.sqlcode);
sqlcode is defined as sqlint32 - why are you truncating this field to 16 bits?
Jan M. Nelken
shorti - 02 Feb 2006 14:24 GMT
The sqlcode is 72 regardless of the truncation.
> hmm...I was hoping it was just a missed sqlcode. I dont think you are
> going to be able to determine much by the info I have. This is just
[quoted text clipped - 5 lines]
> sprintf(logstr, "Error from DECLARE, SQLCODE %d ",
> (short)sqlca.sqlcode);
You should fix this line.
(1) %d expects an "int" value, not a short (gcc will complain about this
rightfully if you have -Wall turned on).
(2) you should truncate the sqlcode in the first place.
You are right, the truncation is not a problem _today_ as the largest
absolute sqlcode in DB2 is -30108.
> the logs says:
> 2006.02-01.10:14:14.681992 c0v0 XDB Error from DECLARE, SQLCODE 72
There is obviously a but more to the "logging" than you have shown us.
Could you possibly provide some more code?
> There is nothing between the EXEC, sprintf and the 'if'. logstr is
> also plenty long enough.
You could collect a DB2 trace as you will see the complete SQLCA structure
in there.

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany
Knut Stolze - 02 Feb 2006 16:53 GMT
> (2) you should truncate the sqlcode in the first place.
should not!!

Signature
Knut Stolze
DB2 Information Integration Development
IBM Germany