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: Oracle SQL question

Re: Oracle SQL question

From: Emmanuel <zouzou_at_yahoo.com>
Date: 14 Jan 2000 15:15:51 GMT
Message-ID: <01bf5eab$1445cac0$3601017e@EHM.cirra.fr>


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;

end;

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

Original text of this message

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