SQLERRD(3)

Rao A

SQLERRD(3)
We are curently on DB2 version 7.0 and most of the COBOL\DB2 programs have "UPDATEs ...." followed by "SELECT count(*) ..."to count the updated rows in the prior UPDATE statement. There are no other columns in the table (like Timestamp columns) that would help us in knowing the updated rows.

I wanted to suggest developers to use SQLERRD(3) of SQLCA field value immediately after the UPDATE statement to know the count on the updated rows and avoid SELECT COUNT(*) sql call.

I would like to know if there is any flip side by using SQLERRD(3) verses SELECT COUNT(*)....

Thanks
Rao
Sr DB2 DBA


____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

The IDUG DB2-L Listserv is only part of your membership in IDUG. DB2-L list archives, the FAQ, and delivery preferences are at http://www.idug.org/lsidug under the Listserv tab. While at the site, you can also access the IDUG Online Learning Center, Tech Library and Code Place, see the latest IDUG conference information, and much more. If you have not yet signed up for Basic Membership in IDUG, available at no cost, click on Member Services at http://www.idug.org/lsms

Peter Vanroose

Re: SQLERRD(3)
(in response to Rao A)
> I would like to know if there is any flip side by using
> SQLERRD(3) verses SELECT COUNT(*)....

Of course: since SQLERRD is always available (whether used or not),
performing an additional SELECT count(*) is always more expensive.
Moreover, since there will be some kind of "code duplication"
between the UPDATE and the SELECT count(*), there's always the risk
that the two don't match and that you get and incorrect count.

Bottomline: always use SQLERRD(3).
(And from DB2 v8 on, start using SELECT from UPDATE.)

-- Peter Vanroose
ABIS Training & Consulting
Leuven, Belgium


















__________________________________________________________
Ta semester! - sök efter resor hos Yahoo! Shopping.
Jämför pris på flygbiljetter och hotellrum här:
http://shopping.yahoo.se/c-169901-resor-biljetter.html?partnerId=96914052

The IDUG DB2-L Listserv is only part of your membership in IDUG. DB2-L list archives, the FAQ, and delivery preferences are at http://www.idug.org/lsidug under the Listserv tab. While at the site, you can also access the IDUG Online Learning Center, Tech Library and Code Place, see the latest IDUG conference information, and much more. If you have not yet signed up for Basic Membership in IDUG, available at no cost, click on Member Services at http://www.idug.org/lsms