Home » SQL & PL/SQL » SQL & PL/SQL » can i use union in pl/sql??
icon5.gif  can i use union in pl/sql?? [message #185082] Sun, 30 July 2006 23:10 Go to next message
alexyap1984
Messages: 3
Registered: July 2006
Junior Member
can i use union in pl/sql???
if yes how can i write the code?? plz show it to me...
Re: can i use union in pl/sql?? [message #185103 is a reply to message #185082] Mon, 31 July 2006 00:52 Go to previous messageGo to next message
navkrish
Messages: 189
Registered: May 2006
Location: NJ,USA
Senior Member

where do you what to use it actually...in declare section?

Naveen
Re: can i use union in pl/sql?? [message #185112 is a reply to message #185082] Mon, 31 July 2006 01:15 Go to previous message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member


SQL> CREATE OR REPLACE PROCEDURE sho_emp_all
  2  AS
  3  BEGIN
  4  FOR rec IN (SELECT ename FROM EMP UNION
  5                 SELECT ename FROM EMP1 )
  6  LOOP
  7     DBMS_OUTPUT.PUT_LINE (rec.ename);
  8  END LOOP;
  9  END;
 10  /

Procedure created.

SQL> Begin
  2  sho_emp_all;
  3  END;
  4  /
ADAMS
ALLEN
BARBARA
BLAKE
CLARK
FORD
FRANK
JAMES
JONES
JROW
KING
MAHER
MAHESH
MARTIN
MILLER
RAJUVAN
SCOTT
SMITH
TURNER
WARD
WILLIAMS
ZOZO

PL/SQL procedure successfully completed.

SQL>


Thumbs Up
Rajuvan
Previous Topic: Triggers In package
Next Topic: Passing parameters
Goto Forum:
  


Current Time: Sun Dec 04 10:26:07 CST 2016

Total time taken to generate the page: 0.17065 seconds