标签:
create or replace procedure generate_insert_sql(t_name in varchar2,execute_sql out varchar2) as CURSOR col_cur is select column_name, data_type from user_tab_cols where table_name like t_name; col_name varchar2(500); BEGIN FOR col in col_cur loop if col.data_type=‘CLOB‘ then col_name := ‘ to_char(‘ || col.column_name || ‘) as ‘||col.column_name||‘ ,‘; else col_name := col.column_name || ‘,‘; end if; execute_sql := execute_sql || col_name; end loop; execute_sql := ‘select ‘ ||RTRIM(execute_sql,‘,‘)|| ‘ from ‘||t_name; end;
测试例子如下,测试工具为PL/SQL
1.创建测试表
create table test_table( name varchar2(30), test_clob1 clob, test_clob2 clob );
2.插入初始化数据
3.执行存储过程
标签:
原文地址:http://www.cnblogs.com/kangyl/p/5076148.html