Re: [INTERFACES] ecpg SQL-return codes?

From: Benedikt Eric Heinen <beh(at)icemark(dot)ch>
To: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] ecpg SQL-return codes?
Date: 1998-07-16 15:22:36
Message-ID: Pine.LNX.4.00.9807161719040.16222-100000@fenun.icemark.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> > how do I determine the result from an SQL statement in an ecpg source?
> > >From using adabas/oracle I am somewhat used to using sqlca.sqlcode, but
> > when I did a simple test yesterday (trying to update a row in an empty
> > table, which of course fails, since there is nothing to update in the
> > table) reveiled sqlca.sqlcode to have a value of 0.
> Well, it of course succeeded! :)

Not quite of course, though...

> SQL is set-oriented, and updating no matching rows is a valid result.

In interactive mode, that is correct. Still, after Hannu personally mailed
me with a similar answer, I dug up the Oracle manual and looked at Server
SQL reference topic "UPDATE (embedded)", where I found:

If no rows satisfy the condition, no rows are updated and Oracle7
returns an error message through the SQLCODE element of the SQLCA.

Also, checking the online documentation for Adabas D (which in the
precompiler is able to emulate ANSI SQL, DB/2, Oracle and its own SQL
flavour to furnish most users needs), I found on the topic of UPDATE:

[MODE= ANSI SQL]
12. If no row is found for which the conditions
defined by the optional clauses are satisfied, the
SQLSTATE 02000 - ROW NOT FOUND - is set.

[MODE= DB2 SQL]
12. If no row is found for which the conditions
defined by the optional clauses are satisfied, the
message 100 - ROW NOT FOUND - is set.

[MODE= Oracle SQL]
12. If no row is found for which the conditions
defined by the optional clauses are satisfied, the
message 100 - ROW NOT FOUND - is set.

[MODE= Adabas SQL]
16. If no row is found for which the conditions
defined by the optional clauses are satisfied, the
message 100 - ROW NOT FOUND - is set.

So, it seems like in embedded mode, quite a few databases see an update of
0 rows to be at least qualifying for warning 100. I think, pgsql should
basically do the same... Don't you?

Benedikt

ULTIMATUM, n. In diplomacy, a last demand before resorting to concessions.
[Ambrose Bierce, "The Devil's Dictionary"]

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruce Momjian 1998-07-16 15:33:35 Re: [INTERFACES] Re: [HACKERS] changes in 6.4
Previous Message Bruce Momjian 1998-07-16 15:18:01 Re: [DOCS] Re: [INTERFACES] libpq & user