日期:2014-05-17 浏览次数:20872 次
CREATE OR REPLACE PROCEDURE p01(tablename IN VARCHAR2) AS v_sql VARCHAR2(500):= 'DECLARE type c_curref is ref cursor; r_curref c_curref; rec_c '||tablename||'%ROWTYPE; BEGIN OPEN r_curref FOR ''select * from '||tablename|| ' where rownum=1''; LOOP FETCH r_curref INTO rec_c; EXIT WHEN r_curref%NOTFOUND; Dbms_Output.put_line(''the SEQUENCE_NAME is :''||rec_c.SEQUENCE_NAME); END LOOP; CLOSE r_curref; END;'; BEGIN execute immediate v_sql; END p01; EXEC p01('user_sequences'); 输出: the SEQUENCE_NAME is :S_DHBA2_SQNO