plsql - procedure using record type -
i create procedure returns list of first 5 records. must use record type , table type. doing wrong?
create or replace procedure procedure_example(v_table out v_rec) cursor cur1 select * ( select type_note, note dd_note order type_note) rownum < 5; type v_rec record ( v_type_note number(2) , v_note varchar(30)); type v_table table of v_rec index binary_integer; begin open cur1; loop fetch cur1 v_type_note, v_note; dbms_output.put_line(v_type_note || '. --- ' || v_note); exit when cur1%notfound; --enter code here end loop; close cur1; end procedure_example;
the place declared types wrong. must declare type "v_rec" , type "v_table" in package procedure belongs, not inside procedure. here's improved version of code. first, declare these types in package:
type v_rec record( v_type_note number(2), v_note varchar(30)); type v_table table of v_rec index pls_integer;
then here's function:
create or replace procedure procedure_example (out_table out v_table) begin select type_note, note bulk collect out_table (select type_note, note dd_note order type_note) rownum < 5 in 1..out_table.count loop dbms_output.put_line(out_table(i).v_type_note || '. --- ' || out_table(i).v_note); end loop; end procedure_example;
Comments
Post a Comment