Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQLPLUS vs PL/SQL question
In article <1998062314150400.KAA26085_at_ladder03.news.aol.com>,
iancrozier_at_aol.com (Iancrozier) wrote:
>
> I need to change the value in one column of a table by adding the value of a
> column in a different table to it and putting the result back into the
original
> column of the first table i.e. I want
> column 1 of table 1 to equal column 1 of table 1 plus column 2 of table 2.
> I know how to do it in PL/SQL with variables etc, but is there a way in
SQLPLUS
> to achieve the same result?
>
> TIA
>
Sure, just use a correlated subquery like below
UPDATE net_worth n SET balance =
(
SELECT n2.balance + s.balance
FROM net_worth n2, savings s
WHERE n2.acct_id = s.acct_id AND n.acct_id = n2.acct_id
);
Geoffrey Bray
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Tue Jun 23 1998 - 14:09:18 CDT