Posted 1/18/2009 10:18:31 AM
|
|
|
|
Hello Friends,
I have created one procedure which uses Bulk collect and nested table to hold the bulk data. This procedure was using one cursor and a nested table with the same type as the cursor to hold data fetched from cursor. Bulk collection technique was used to collect data from cursor to nested table. But it is giving ORA-06502 ora error.
I reduced code of procedure to following to trace the error point. But still the ora error is coming. Please help us to find the cause and solve it.
Script which is giving error: declare v_Errorflag BINARY_INTEGER; v_flag number := 1; CURSOR cur_terminal_info Is SELECT distinct 'a' SettlementType FROM dual; TYPE typ_cur_terminal IS TABLE OF cur_terminal_info%ROWTYPE; Tab_Terminal_info typ_cur_Terminal; BEGIN v_Errorflag := 2; OPEN cur_terminal_info; LOOP v_Errorflag := 4; FETCH cur_terminal_info BULK COLLECT INTO tab_terminal_info LIMIT 300; EXIT WHEN cur_terminal_info%rowcount <= 0; v_Errorflag := 5; FOR Y IN Tab_Terminal_Info.FIRST..tab_terminal_info.LAST LOOP dbms_output.put_line(v_flag); v_flag := v_flag + 1; end loop; END LOOP; v_Errorflag := 13; COMMIT; END;
I have updated script as following to change datatype as varchar2 for nested table, but still same error is comming..
declare v_Errorflag BINARY_INTEGER; v_flag number := 1; CURSOR cur_terminal_info Is SELECT distinct 'a' SettlementType FROM dual; TYPE typ_cur_terminal IS TABLE OF varchar2(50); Tab_Terminal_info typ_cur_Terminal; BEGIN v_Errorflag := 2; OPEN cur_terminal_info; LOOP v_Errorflag := 4; FETCH cur_terminal_info BULK COLLECT INTO tab_terminal_info LIMIT 300; EXIT WHEN cur_terminal_info%rowcount <= 0; v_Errorflag := 5; FOR Y IN Tab_Terminal_Info.FIRST..tab_terminal_info.LAST LOOP dbms_output.put_line(v_flag); v_flag := v_flag + 1; end loop; END LOOP; v_Errorflag := 13; COMMIT;
I could not find the exact reason of error. Please help us to solve this error.
Thanks and Regards..
|
|
Posted 1/18/2009 10:19:21 AM
|
|
|
|
Hello Friends,
I found the solution 
I did one mistake in procedure where the loop should end.
I used the statement: EXIT WHEN cur_terminal_info%rowcount <= 0;
But it should be: EXIT WHEN Tab_Terminal_Info.COUNT <= 0;
Now my script is working fine now. 
Thanks and Regards,
|
|
|
|