sqlca structure - Mailing list pgsql-novice

From Atif Jung
Subject sqlca structure
Date
Msg-id AANLkTik5Tv8k3hYB_HW8r1Vi2_tCfiq7y9Zv2EnLuoRG@mail.gmail.com
Whole thread Raw
List pgsql-novice
In ECPG, there are instances when I'm not concerned about the error/warning generated by a piece of SQL. In those instances I'm using EXEC SQL WHENEVER ERROR CONTINUE; However as I understand it, the sqlca structure which holds the warnings and errors, remains populated, so that when I do check for an error after a subsequent SQL command, even if that command DID NOT fail, POSTGRES will still report an error from the previous SQL command which did and for which I did a CONTINUE.
 
My question is, is there a simple way to reset the sqlca structure after doing a CONTINUE?
 
For example:
 
EXEC SQL DROP INDEX index1;
EXEC SQL WHENEVER ERROR CONTINUE;  /* Don't care about the error, just continue */
 
EXEC SQL SELECT col1 FROM table1 WHERE col2 = :acString;
if (strncmp(sqlca.sqlstate, '00', 2) != 0)
{
    /* Report error/warning here */
}
 
In the above example if the DROP INDEX errors or gives a warning, then even if the SELECT works ok, the strncmp will still pick up the error from the DROP INDEX, which is what I want to avoid. so how do I reset the sqlca structure after the DROP INDEX command?
 
Finally if the DROP INDEX gives a warning do I need to explicity check for that with an EXEC SQL WHENEVER WARNING CONTINUE, or will the WHENEVER ERROR pick that up as well?
 
I hope all that makes sense.
 
Many thanks.

Atif


pgsql-novice by date:

Previous
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: RI
Next
From: Atif Jung
Date:
Subject: DECLARING & OPENING SURSORS