How to add array in existing oracle sql cursor -
i dealing more 25 tables having association , need return simple array/cursor stored procedure.
make simple question providing below example:-
for mentioned below scenario want add subjects against each student means in existing emp_curr want add result of sub_cur.
cursor emp_curr select st_id,st_name,st_surname student; begin n in emp_curr loop declare cursor sub_cur select sub_id,subject student_subjects st_id_fk=n.st_id; begin c in sub_cur loop -- here want store sub_cur values in existing emp_curr end loop; end; end loop; end;
final output
|-----------|--------------|----------|---------------|- |student id | student name |student id|student subject| |-----------|--------------|----------|---------------|- | 1 | prashant | 2 | maths | | 1 | prashant | 4 | english | | 1 | prashant | 3 | science | |-----------|--------------|----------|---------------|- | 2 | shailndra | 1 | hindi | | 2 | shailndra | 5 | geo | | 2 | shailndra | 7 | chemical | |-----------|--------------|----------|---------------|-
great if can me have spent 4 hours , gone in vain.
prashant thakre, how you? perhaps misunderstood question, explain myself , hopefully, you. first thing realized scenario it's odd. cannot change oracle cursor structure once have declared it. more that, don't see need implement such procedure. use 2 columns table student, right? then, need 2 more columns added data set, 2 coming table student_subjects. , seems exist referential integrity between tables, because have equijoin condition in second cursor's query ( ...where st_id_fk=n.st_id)
so, wonder, why don't open first cursor setting following query, don't need add columns "by hand"?
select s.st_id,s.st_name,s.st_surname,sb.sub_id,sb.subject student s,student_subjects sb s.st_id=sb.st_id_fk
using query, have want looking for, needing. again, maybe misunderstood issue, want you. so, give more ight"on subject if query not need.
best regards. jorge.
Comments
Post a Comment