createorreplaceprocedurePROC_testis--Description:删除字段中的指定字符(回车chr(13)、换行chr(10))--ByLiChao--Date:2016-03-01colnamevarchar(20);--列名cntnumber;--包含换行符的列的行数v_sqlvarchar(2000);--动态SQL变量begin--读取表中的列forcolin(selectcolumn_namefromuser_tab_columnswheretable_name='TEMP')loopcolname:=col.column_name;--替换换行符chr(10)v_sql:='selectcount(1)fromtempwhereinstr('||colname||',chr(10))>0';EXECUTEIMMEDIATEV_SQLintocnt;ifcnt>0thenv_sql:='updatetempset'||colname||'=trim(replace('||colname||',chr(10),''''))'||'whereinstr('||colname||',chr(10))>0';EXECUTEIMMEDIATEV_SQL;commit;endif;--替换回车符chr(13)v_sql:='selectcount(1)fromtempwhereinstr('||colname||',chr(13))>0';EXECUTEIMMEDIATEV_SQLintocnt;ifcnt>0thenv_sql:='updatetempset'||colname||'=trim(replace('||colname||',chr(13),''''))'||'whereinstr('||colname||',chr(13))>0';EXECUTEIMMEDIATEV_SQL;commit;endif;--替换'|'chr(124)为'*'chr(42)v_sql:='selectcount(1)fromtempwhereinstr('||colname||',chr(124))>0';EXECUTEIMMEDIATEV_SQLintocnt;ifcnt>0thenv_sql:='updatetempset'||colname||'=replace('||colname||',chr(124),chr(42))'||'whereinstr('||colname||',chr(124))>0';EXECUTEIMMEDIATEV_SQL;commit;endif;endloop;endPROC_test;/