create or replace procedure pro_Supplement_Leave_Mapping AS
CURSOR TEMP_CUR IS
select d.table_name, d.comments, t.num_rows
from user_tab_comments d
inner join user_tables t
on d.table_name = t.TABLE_NAME
left join user_col_comments c
on d.table_name = c.table_name
where c.column_name='ID'
and t.NUM_ROWS > 0;
v_tablename VARCHAR2(4000);
v_column VARCHAR2(4000);
STRSQL VARCHAR2(4000);
P_VALUE VARCHAR2(4000);
begin
For TEMP_CUR_RECORD in TEMP_CUR loop
v_tablename := TEMP_CUR_RECORD.table_name;
v_column :=TEMP_CUR_RECORD.comments;
BEGIN
P_VALUE := '(select max(id) from '||v_tablename || ' where rownum=1)'; --??????????????????
STRSQL :='insert into SEQCESHI(table_name,column_name,maxid)values('''||v_tablename||''','''||v_column||''','||P_VALUE||')';
execute immediate STRSQL;
commit;
END;
end loop;
end pro_Supplement_Leave_Mapping;