Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle SQL question
Use a PL/SQL program with a cursor and a loop.
Store the data to update in a program variable.
declare
VarField1 MyTable.field1%type; RightValue MyTable.field1%type; MyField2 MyTable.field2%type; cursor MyCurs is select field1 from MyTable where field1!=RightValue; begin select field2 into MyField2 from MyTable where field1=RightValue; open MyCurs; loop fetch MyCurs into VarField1; exit when MyCurs%NOTFOUND; update MyTable set field2=MyField2 where field1=VarField1; end loop; close MyCurs;
I guess this is a theorical problem.
What is the point of having a table with 1500 identical rows?
Michael Francis Horrocks <M.F.Horrocks_at_informasa.es> a écrit dans l'article
<387F149E.E3B58C5E_at_informasa.es>...
> All,
> I am a newbie DBA and one of my Users has laid the following
> problem on my desk
> can anyone help?
>
> I have a table with the following columns:
>
> field1 VARCHAR2(50)
> field2 LONG RAW (store graphical)
>
> this table has 1.500 rows
>
> The problem is that I have to update 1.499 rows with the one row which
> is correct
> (I know which one is correct) How can I do it?
> I can't use sub queries with long raw type.
>
>
> Regards,
> Michael
>
Received on Fri Jan 14 2000 - 09:15:51 CST
![]() |
![]() |