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: Update question

Re: Update question

From: Phil Kaufman <philk_at_dbcsmartsoftware.com>
Date: Fri, 23 May 2003 15:00:29 -0400
Message-ID: <zTuza.226$%w1.68184118@mantis.golden.net>


Sorry, I figured it out. I did something like:

Update <some table>
SET <some column> = (SELECT a.<some column> + b.<some column>

                                      FROM <some table> a,
                                                  <some table> b
                                     WHERE .....)

I used Cartesian product join of two 1 record selects (table a and table b). It's not pretty, but it works. ;-)

Phil

"Phil Kaufman" <philk_at_dbcsmartsoftware.com> wrote in message news:k1sza.219$hk1.67908696_at_mantis.golden.net...
> Hi everyone,
>
> This is for Oracle 8.0.5 (and above possibly).
>
> When I attempt to write an update statement with the following syntax:
>
> UPDATE <some table>
> SET <some column> = (SELECT 1 FROM DUAL) +
> (SELECT 2 FROM DUAL)
> /
>
> I get an error:
>
> SET number_of_batches = (SELECT 1 FROM DUAL) +
> *
> ERROR at line 2:
> ORA-00933: SQL command not properly ended
>
> My question: How to have a single update contain two sub-select? I tried
> the idea of:
>
> UPDATE <some table>
> SET <some column> = (SELECT tab1.col1 + tab2.col1
> FROM (SELECT 1 AS col1 FROM DUAL tab1),
> (SELECT 2 AS col1 FROM DUAL tab2)
> /
>
> but, no good, same error.
>
> Anyone have any ideas?
>
> Thanks very much in advance.
>
> Phil
>
>
Received on Fri May 23 2003 - 14:00:29 CDT

Original text of this message

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