sqlca structure

From: Atif Jung <atifjung(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: sqlca structure
Date: 2010-06-24 12:05:20
Message-ID: AANLkTik5Tv8k3hYB_HW8r1Vi2_tCfiq7y9Zv2EnLuoRG@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-novice by date

  From Date Subject
Next Message Atif Jung 2010-06-24 14:06:14 DECLARING & OPENING SURSORS
Previous Message Jean-Yves F. Barbier 2010-06-24 11:39:45 Re: RI