Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Is it Possible to Update a table with a fetched cursor record?
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
Here is an 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 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:55:25 CDT
![]() |
![]() |