Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
14Activity
0 of .
Results for:
No results containing your search query
P. 1
PL/SQL Record

PL/SQL Record

Ratings: (0)|Views: 842 |Likes:
Published by writesmd
Oracle Pl/Sql Record
Oracle Pl/Sql Record

More info:

Published by: writesmd on Jul 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

 
PL /SQL RECORD----------------------------DeclareType r1 is record(empno number(5),ename varchar2(10),hiredate date);r2 r1;Beginselect empno,ename,hiredate into r2 from emp where empno=&Ask_Empno;dbms_output.put_line(r2.empno||' '||r2.ename||' '||r2.hiredate);Exceptionwhen no_data_found thenraise_application_error(-20023,'Invalid Employee Number');End;------------------------------------------------------------------------------------------------------------------------------------With Procedure-----------------------set serverout on;create or replace procedure pr_plrecord (eno emp.empno%type) isType r1 is record(empno number(5),ename varchar2(10),hiredate date);r2 r1;BeginSelect empno,ename,hiredateinto r2from empwhere empno=eno;dbms_output.put_line(r2.empno||' '||r2.ename||' '||r2.hiredate);Exceptionwhen no_data_found thenraise_application_error(-20023,'Invalid Employee Number');End;------------------------------------------------------------------------------------------------------------------------------------With Cursor / Procedure-----------------------------------set serverout on;create or replace procedure pr1 (dno emp.deptno%type) isType r1 is record(empno number(5),ename varchar2(10),hiredate date);r2 r1; cursor c1 isSelect empno,ename,hiredateFrom empWhere deptno=dno;BeginOpen c1;Loop
 
Exit when c1%notfound;Fetch c1 into r2;dbms_output.put_line(r2.empno||' '||r2.ename||' '||r2.hiredate);End Loop;Close c1;Exceptionwhen no_data_found thenraise_application_error(-20023,'Invalid Department Number');End;/show err------------------------------------------------------------------------------------------------------------------------------------With Cursor / Procedure -- Joins----------------------------------------set serverout on;create or replace procedure pr2 (dno emp.deptno%type) isType r1 is record(empno number(5),ename varchar2(10),hiredate date,loc dept.loc%type);r2 r1;cursor c1 isSelect empno,ename,hiredate,locFrom emp,deptWhere emp.deptno=dno and dept.deptno=emp.deptno;BeginOpen c1;LoopExit when c1%notfound;Fetch c1 into r2;dbms_output.put_line(r2.empno||' '||r2.ename||' '||r2.hiredate||' '||r2.loc);End Loop;Close c1; Exceptionwhen no_data_found thenraise_application_error(-20023,'Invalid Department Number');End;/show err-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------PL/SQL TABLE - 1-------------------------------set serverout on;Declare
 
Type r1 is table of emp.ename%type index by binary_integer;r2 r1;i binary_integer:=0;BeginFor r3 in (Select ename from emp)Loopi:=i+1;r2(i):=r3.ename;dbms_output.put_line(r2(i));End Loop;End;/show err ---------------------------------------------------------------------------------------------------------------------------------------------------------PL/SQL TABLE - 2-------------------------------DeclareType r1 is table of dept%rowtype index by Binary_Integer;r2 r1;Beginfor i in 1..10Loopselect * into r2(i) from dept where deptno=10;dbms_output.put_line(r2(i).dname ||' '||r2(i).loc||''||r2(i).deptno);End Loop;ExceptionWhen Too_many_rows ThenRaise_Application_Error(-20023,'More than one rows');End;/=========================PL/SQL TABLE - 2A-------------------------------DeclareType r1 is table of dept%rowtype index by Binary_Integer;cursor c1 is select * from dept;r2 r1;i binary_integer:=0;dname varchar2(25);BeginFor a in c1Loopi:=i+1;dbms_output.put_line((i)||' '||a.deptno||' '||a.dname||''||a.loc);dname:=a.dname;

Activity (14)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Madhes Analyst liked this
Amit Kasana liked this
Amit Kasana liked this
qayxswedcvfr liked this
staalin liked this
ndavidd liked this
sporcu88 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->