Re: [INTERFACES] ecpg SQL-return codes? - Mailing list pgsql-interfaces

From Benedikt Eric Heinen
Subject Re: [INTERFACES] ecpg SQL-return codes?
Date
Msg-id Pine.LNX.4.00.9807161719040.16222-100000@fenun.icemark.ch
Whole thread Raw
In response to Re: [INTERFACES] ecpg SQL-return codes?  ("Thomas G. Lockhart" <lockhart@alumni.caltech.edu>)
List 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"]


pgsql-interfaces by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [INTERFACES] ecpg SQL-return codes?
Next
From: Bruce Momjian
Date:
Subject: Re: [INTERFACES] Re: [HACKERS] changes in 6.4