Re: Returning SQLCA values: How?
Posted in 1996
M Ferris wrote:
>
> I have several stored procedures that do an update on a table, such
> as:
>
> update mytable
> set myfield = myvariable
> where mykeyfield = passed_arg.
>
> End procedure
>
> If no rows are found to match my argument, this is not considered an
> error, but shouldn't SQLCA.SQLCode be = 100?
>
> Or the other case, if the update works, is there any way to return the
> number of rows that were updated?
>
> I guess the short question is, how do I get values from SQLCA in my
> stored proc so I can return them to a user?
>
> My environment is a PowerBuilder front end and Informix 5.01
>
> Please copy respnse to email. mferris@wwa.com
>
> Thanks!
> Matt Ferris
Hi Matt,
Inside a procedure you can use the dbinfo( "sqlca.sqlerrd1" ) and
dbinfo("sqlca.sqerrd2" ) function to retrieve the number of rowsprocessed and the serial value after a successful insert.
The ANSI Standard says, that we have to return a status of 0 after
an Update with 0 rows. In earlier versions of Informix they returned
100 ( SQLNOTFOUND ) but starting with ( I think it was 5.x ) they
return 0. So your procedure has to return the value that you retrieved
by the function dbinfo().
Any more questions ?
Bye
Stefan.
stefan@weideneder.de