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 - Help Needed Please

Re: Update Query - Help Needed Please

From: odyssey4 <odyssey4_at_email.msn.com>
Date: Fri, 27 Aug 1999 23:12:44 -0400
Message-ID: <uaBE0RQ8#GA.72@cpmsnbbsa05>


 Hi,
You can try this:

DECLARE
 cursor upd_t1_crs as

            SELECT   t2.id ID,
                               t2.date DATE
                FROM    t1, t2, t3
             WHERE    t1.id =t2.id
                   AND    t2.id =t3.id
                   AND    t1.date IS NULL
                   AND    t2.date IS NOT NULL
                   AND    t3.name IS NOT NULL;
BEGIN
   FOR CUR IN upd_t1_crs LOOP
         UPDATE t1
                 SET date = CUR.DATE
          WHERE ti.id = CUR.ID;

   END LOOP;
   COMMIT;
   EXEPTION
   when others then
 rollback;
END; Regards,
Mitch.

Dipen Kotecha <dkotecha_at_ford.invalid> wrote in message news:37C699B0.A6CE06DC_at_ford.invalid...
> This seems quite complex to me as I do not often write updates.
> Hopefully someone can help.
>
> The following select query shows me the rows that I need to update. The
> problem is the correct syntax for turning it into an update query.
>
> SELECT t1.date
> FROM t1, t2, t3
> WHERE
> t1.date IS NULL
> and t1.id=t2.id
> and t2.date IS NOT NULL
> and t1.id=t3.id
> and t3.name IS NOT NULL
>
> Now this query will give me a whole set of NULL dates as the result.
> What I need to do is to update those dates (t1.date) to t2.date only for
> the dates returned by the above query. All three tables are linked by
> id, a unique key.
>
> Any help or advice will be greatly appreciated. Thanks in advance,
>
>
> Dipen
Received on Fri Aug 27 1999 - 22:12:44 CDT

Original text of this message

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