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: Is it Possible to Update a table with a fetched cursor record?

Re: Is it Possible to Update a table with a fetched cursor record?

From: <Jiri.Felcman_at_noofs.abb.no>
Date: Tue, 21 Sep 1999 10:56:52 GMT
Message-ID: <7s7o9g$498$1@nnrp1.deja.com>


In article <37e6a14f.25260210_at_news.supernews.com>,   gcoyle_at_cbs.webramp.net wrote:
> If you fetch a record like firstname,last name,number in a cusror from
> table1 and want to update Table2
>
> what is the proper plsql syntax to do something like this?
> with cursor do
> update table2
> set table2.firstname = cusror.firstname
> set table2.lastname = cusror.lastname
> set table2.number = cusror.number
> end;
>
> Thanks for you help
> GC

Try following example:

create table dual_my as select * from dual; update dual_my set dummy = 'f';
select dummy from dual_my;

CREATE OR REPLACE PACKAGE test_pck IS

PROCEDURE do;

END test_pck;
/

CREATE OR REPLACE PACKAGE BODY test_pck IS

procedure do is

	CURSOR f_cursor IS
	SELECT dummy from dual;

BEGIN

	FOR fc_current_row IN f_cursor
	LOOP
		UPDATE dual_my
		SET dummy = fc_current_row.dummy;
	END LOOP;
	COMMIT;

END do ;

END test_pck;
/

exec test_pck.do;
select dummy from dual_my;

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Tue Sep 21 1999 - 05:56:52 CDT

Original text of this message

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