UPDATE & FETCH FIRST

Patricia Anderson

UPDATE & FETCH FIRST
Hello,
 
Is there a simple way to update, lets say only 5 records in a table ?
 
I was using the FETCH FIRST...ONLY clause:
 
 UPDATE creatorid.table_name1      
 SET fields1 = value            
 WHERE (SELECT *           
 FROM creatorid.table_name1               
 FETCH FIRST 10 ROWS ONLY);  
 
But it does't seem to work with the UPDATE statement.
The rows may be read only and can't be used.
 
Does anybody know of a work-around for it ?
 
I'm hoping not having to code a cobol program to do this.
 
Cheers,
Patricia




______________________________________________________________________

* IDUG 2009 Denver, CO, USA * May 11-15, 2009 * http://IDUG.ORG/Events *
______________________________________________________________________




IDUG.org was recently updated requiring members to use a new password. You should have gotten an e-mail with the temporary password assigned to your account. Please log in and update your member profile. If you are not already an IDUG.org member, please register at http://www.idug.org/component/juser/register.html

Gregory Palgrave

Re: UPDATE & FETCH FIRST
(in response to Patricia Anderson)
I think your update syntax is slightly wrong - this works on LUW, not sure about z/OS these days:

UPDATE
(SELECT *
FROM creatorid.table_name1
FETCH FIRST 10 ROWS ONLY)
SET fields1 = value ;

Regards,

Greg



From: DB2 Data Base Discussion List [mailto:[login to unmask email] On Behalf Of Patricia Anderson
Sent: Tuesday, 20 January 2009 4:11 AM
To: [login to unmask email]
Subject: [DB2-L] UPDATE & FETCH FIRST

Hello,

Is there a simple way to update, lets say only 5 records in a table ?

I was using the FETCH FIRST...ONLY clause:

UPDATE creatorid.table_name1
SET fields1 = value
WHERE (SELECT *
FROM creatorid.table_name1
FETCH FIRST 10 ROWS ONLY);

But it does't seem to work with the UPDATE statement.
The rows may be read only and can't be used.

Does anybody know of a work-around for it ?

I'm hoping not having to code a cobol program to do this.

Cheers,
Patricia


________________________________

IDUG 2009 - North America * May 11-15 * Denver, Colorado, USA < http://idug.org/lsna >

IDUG.org <http://www.idug.org> was recently updated requiring members to use a new password. You should have gotten an e-mail with the temporary password assigned to your account. Please log in and update your member profile. If you are not already an IDUG.org member, please register here.< http://www.idug.org/component/juser/register.html >

______________________________________________________________________

* IDUG 2009 Melbourne, Australia * 18-20 March * http://IDUG.ORG/Events *
______________________________________________________________________




IDUG.org was recently updated requiring members to use a new password. You should have gotten an e-mail with the temporary password assigned to your account. Please log in and update your member profile. If you are not already an IDUG.org member, please register at http://www.idug.org/component/juser/register.html