Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Limit UPDATE statements to affect only one row

Re: Limit UPDATE statements to affect only one row

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 11 Aug 2006 16:37:52 -0700
Message-ID: <1155339472.649995@bubbleator.drizzle.com>


Serge Rielau wrote:
> DA Morgan wrote:

>> Serge Rielau wrote:
>>> And, no, I don't have Oracle installed any more than you have IDS 
>>> installed. At least my contributions are constructive. :-)
>> You don't think I have IDS installed ... On what basis?
>> This is a university ... we have everything installed.
>> If someone sold it, gave it away, or lost it ... we have it.
>> And so do I. ;-)

> And this is IBM. Premier Oracle partner IBM ;-)

For enough money my mother could be a Premier Partner too. ;-)

> UPDATE emp SET sal = 1 WHERE rownum <= 1
> => Works!

So does:
UPDATE emp SET sal = 1 WHERE rownum = 1; which was my point. Less than or equal to has not context as less than is impossible. You can not update zero rows.

> UPDATE (SELECT sal FROM emp WHERE rownum <= 1) SET sal = 1
> => Doesn't work

I often find using a valid syntax improves things in Oracle. Perhaps that isn't required with DB2.

UPDATE (
   SELECT sal
   FROM emp)
SET sal = 1
WHERE rownum = 1;

> Oh well
> Serge

Oh well indeed. ;-)

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Fri Aug 11 2006 - 18:37:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US