Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

passing an output from one cursor to another curosr

Uday_NMay 15 2018 — edited May 15 2018

Hi All,

            I am passing an output from first cursor to second cursor  I get zero records. The output of first cursor shows 1000 records and when I pass the value it shows 0 but if pass the 'hard coded values from first cursor it gives records ' . I think there was some mistake in my coding.Please kind your help.

eg :

create or replace procedure p1 is

cursor c1 is

select emp_name , emp_id ,emp_doj from employee ;

cursor c2 (v_emp_id employee.emp_id%type, v_emp_doj employee.emp_doj%type, v_emp_name employee.emp_name%type) is

select emp_salary , dept_name , dept_manager from department

where emp_name = v_emp_name

and emp_id = v_emp_id

and emp_doj =v_emp_doj ;

TYPE c1_tab IS TABLE OF c1%ROWTYPE INDEX BY BINARY_INTEGER;   
c1_rec             c2_tab;

TYPE  c2_tab  IS TABLE OF  c2%ROWTYPE INDEX BY BINARY_INTEGER;
c2_rec            c2_tab ;

open c1 ;

fetch c1 bulk collect into c1_rec ;

open c2(v_emp_id,v_emp_doj,v_emp_name) ;

fetch c2 bulk collect into c2_rec;

if c1_rec.count> 0

for I in 1..c1_rec.count loop

for j in 1..c2_rec.count loop

--------an insert function----

end loop;

end loop;

end if ;

end p1 ;

I am getting values of emp_name,emp_id and emp_doj but when I pass it to second cursor c2 I am getting zero records although if pass the values to select statement of that cursor I am getting records. Please kind your help

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2018
Added on May 15 2018
7 comments
4,343 views