Re: New to SQL Analytics and need help

From: Pratap <pratap_fin_at_rediffmail.com>
Date: 24 Sep 2004 02:42:36 -0700
Message-ID: <830861d2.0409240142.76cb6f9e_at_posting.google.com>


You have to lead LAG instead of LEAD

To update, if you have few rows then this will work fine -

begin
 for rec in
 (
   select lead(old_loc) over (partition by id order by operation_dt) a, rowid rid

   from tab_name
 )
 loop

    update tab_name set new_loc = rec.a where rowid = rid  end loop;
end;

But if you have too many rows and performance is an issue then use merge command as given here -

http://groups.google.co.in/groups?hl=en&lr=&ie=UTF-8&threadm=830861d2.0409230400.3a1ea0cd%40posting.google.com&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.databases.oracle.server

Regards,

Pratap Received on Fri Sep 24 2004 - 11:42:36 CEST

Original text of this message