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

Home -> Community -> Usenet -> c.d.o.misc -> Re: update query question

Re: update query question

From: Sybrand Bakker <gooiditweg_at_sybrandb.verwijderdit.demon.nl>
Date: Fri, 22 Oct 2004 23:10:25 +0200
Message-ID: <vmtin0h81fqo8bf74ho35ul1m7qva70d92@4ax.com>


On 22 Oct 2004 13:59:24 -0700, j.cawkwell_at_open.ac.uk (Jack) wrote:

>I am trying to update the notification.notify_key
>if it is null, otherwise leave it unchanged. It
>should be set to the appropriate value from
>notify_temp.notify_key.
>
>The following code sets it correctly on the first
>execution, then on the second execution it is set
>to null. This repeats cycling between a value and
>null each time. (not what is needed)
>
>update notification nf set notify_key=(
> select
> decode(nf.notify_key,NULL, tm.notify_key,
> nf.notify_key,nf.notify_key)
> from
> notify_temp tm
> where
> nf.d_machine_key = tm.d_machine_key (+) )
>
>Any suggestions?

Generally speaking if you have a column updated by a subquery, you need to have that subquery in the where clause of the update statement. You don't have such a where clause, so the behavior you see is expected, as you update too many rows.

>
>Thanks, Jack

--
Sybrand Bakker, Senior Oracle DBA
Received on Fri Oct 22 2004 - 16:10:25 CDT

Original text of this message

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