Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Update statement

Status
Not open for further replies.

Emmaar

Programmer
Jan 7, 2003
11
0
0
GB
SELECT LEEN_ID
, TAXD_ORIG_START_DT
, TAXD_TAX_YEAR
, UPDATE_USERID
FROM ANPDBAP.ANPT031
WHERE LEEN_ID IN ('00065118','00065121','00225129',
'00065120','00232147','00040308')
AND TAXD_TAX_YEAR = 2003
AND TAXD_END_DATE = '31.12.2099'
;

---------+---------+---------+---------+---------+---------
LEEN_ID TAXD_ORIG_START_DT TAXD_TAX_YEAR UPDATE_USERID
---------+---------+---------+---------+---------+---------
00040308 14.02.1996 2003. APSYSTEM
00065118 02.08.1993 2003. APSYSTEM
00065120 06.04.1994 2003. APSYSTEM
00065121 18.05.1999 2003. APSYSTEM
00225129 21.09.1998 2003. APSYSTEM
00232147 06.04.2000 2003. APSYSTEM
DSNE610I NUMBER OF ROWS DISPLAYED IS 6
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------


UPDATE ANPDBAP.ANPT031
SET TAXD_ORIG_START_DT = '06.04.2003'
, UPDATE_USERID = 'I45294A'
, TIMESTAMP = CURRENT TIMESTAMP
WHERE LEEN_ID IN ('00065118','00065121','00225129',
'00065120','00232147','00040308')
AND TAXD_TAX_YEAR = 2003
AND TAXD_END_DATE = '31.12.2099'
;
---------+---------+---------+---------+---------+---------+--
DSNE615I NUMBER OF ROWS AFFECTED IS 12
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

The WHERE clause in the above select and update statements is the same. But the count differs. Can any help...

Iam using DB2 in OS/390.

Thanks and Regards,
Ramkumar.
 
Hi Ramkumar,

It looks like the SELECT has removed duplicate rows of the LEEN_ID.

What is your unique key for this table? Also, try with a SELECT COUNT(*) to get the number of rows affected.

Let me know the outcome.

-PK

I.T.Analyst
Tata Consultancy Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top