Sunday, 9 June 2013

PL/SQL to fetch data using cursors

Creating a table:

Create table emp_g(eno number,e_name varchar2(20))


Inserting values in the table:

Insert into emp_g(eno,e_name) values(1,'steve');


PL/SQL block:

DECLARE
cursor emp_detail (eno1 number) is select e_name from emp_g where eno=eno1;
eno2 emp_g.eno%type:=2;
name2 emp_g.e_name%type;
BEGIN
Open emp_detail(eno2);
Fetch emp_detail into name2;
dbms_output.put_line(name2);
Close emp_detail;
END;

No comments:

Post a Comment