{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

01JulNotes - end loop end create object record-create type...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Cursor -Explicit cursor function Declare open fetch empty close cursor%isOpen Explicit use for command Implicit use fetch command for emp_rec in (select * from emp) loop ..... ..... end loop cursor with parameters ////////////////////////////////// Cursor with parameter --------------------- declare dat emp%rowtype cursor c1(dno number,salary number) is select * from emp where deptno=dno and sal>salary BEGIN open c1(&dno,&salary) fetch c1 into dat loop dbms_output.put_line(c1%ROWCOUNT ||' EmpNo ' ||dat.empno ||' EmpName ' ||dat.ename ||' EmpSal ' ||dat.sal ) fetch c1 into dat exit when c1%NOTFOUND end loop close c1 end ///////////////////////////////// Impiclit sample --------------- declare emprec emp%rowtype begin for emprec in (select * from emp) loop dbms_output.put_line('Ename ' || emprec.ename || ' Sal :' || emprec.sal)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end loop end /////////////////////////// create object record------------------create type rec_obj as object( ename varchar(20), sal number Sheet1 Page 2 ) create type emp_table as table of rec_obj create table mytable( empno number, detail emp_table, dept number ) nested table detail store as emp_tab insert''''''''''''' insert into mytable values(10,emp_table(rec_obj('Nikorn',200)),10) // 2 cursors at a time Implicit and Explicit set serveroutput on declare dep dept%rowtype em emp%rowtype cursor c1 is select * from emp begin open c1 for dep in (select * from dept) loop fetch c1 into em exit when c1%notfound dbms_output.put_line('Dept: ' || dep.dname || ' Ename :' || em.ename) end loop end...
View Full Document

{[ snackBarMessage ]}