Insert in Pl/sql [message #1226] |
Fri, 12 April 2002 08:30 |
UmaSund
Messages: 22 Registered: February 2002
|
Junior Member |
|
|
Hi
I have this insert statement whose Select statemnt is a union of three select statements.
How can I do this insert in a pl/sql block.
A sample code is apprecaited.
Thanks
-UmaSund
|
|
|
Re: Insert in Pl/sql [message #1229 is a reply to message #1226] |
Fri, 12 April 2002 09:19 |
|
Mahesh Rajendran
Messages: 10707 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
Hope this will help u
------------------------------------------------
SQL> desc e
Name Null? Type
----------------------------------------- -------- ----------------------------
ENAME VARCHAR2(10)
SQL> declare
2 cursor c1 is
3 select ename from emp where deptno=10
4 union
5 select ename from emp where deptno=20;
6 begin
7 for mag in c1 loop
8 exit when c1%notfound;
9 insert into e values(mag.ename);
10 end loop;
11 commit;
12 end;
13 /
PL/SQL procedure successfully completed.
SQL> select * from e;
ENAME
----------
ADAMS
CLARK
FORD
JONES
KING
MILLER
SCOTT
SMITH
8 rows selected.
-----------------------------------------------------
|
|
|