Tuesday, 15 April 2014

plsql - ROWTYPE definition in pl/sql -



plsql - ROWTYPE definition in pl/sql -

i have written pl/sql procedure compares info between 2 tables , print difference if any, twist table names procedure dynamic. here procedure

create or replace procedure comparetables( taba in varchar2, tabb in varchar2) cur_tab_name user_tables%rowtype; lv_sql varchar2(4000); lv_sql2 varchar2(4000); begin --select table_name cur_tab_name user_tables table_name = taba; lv_sql2 := 'select table_name user_tables table_name = :b_taba'; execute immediate lv_sql2 cur_tab_name using taba; <<child>> declare type cursor_ref ref cursor; cur_comp_result cursor_ref; rec_comp_result cur_tab_name.table_name%rowtype; begin lv_sql := 'select * '||taba||' minus select * '||tabb; open cur_comp_result lv_sql; loop fetch cur_comp_result rec_comp_result; exit when cur_comp_result%notfound; dbms_output.put_line(rec_comp_result.empid || '' || rec_comp_result.name); end loop; close cur_comp_result; exception when others dbms_output.put_line('the problem '||sqlerrm); end; end comparetables;

now problem when compile procedure getting next error

error @ line 14: pls-00310: %rowtype attribute, 'cur_tab_name.table_name' must name table, cursor or cursor-variable

line 14:rec_comp_result cur_tab_name.table_name%rowtype;

how solve it?

*nb: don't have oracle installed in system. using oracle apex online tool uses oracle database 11g enterprise edition release 11.2.0.3.0 , pl/sql release 11.2.0.3.0

as test, go lastly line, , after semicolon, nail enter. know pro*c in particular gag without line terminator @ end of file. may encounting issue.

outside scope of question consider

select columns table1 minus select columns table2

and

select columns table2 minus select columns table1

plsql cursor procedure records

No comments:

Post a Comment