oracle删除字段中的空格、回车及指定字符
发布时间:2020-12-12 14:58:39 所属栏目:百科 来源:网络整理
导读:650) this.width=650;" src="http://img.jb51.cc/vcimg/static/loading.png" alt="复制代码" style="border:0px;" src="http://common.cnblogs.com/images/copycode.gif"> createorreplaceprocedurePROC_testis--Description:删除字段中的指定字符(回车chr(
createorreplaceprocedurePROC_testis --Description:删除字段中的指定字符(回车chr(13)、换行chr(10)) --ByLiChao --Date:2016-03-01 colnamevarchar(20);--列名 cntnumber;--包含换行符的列的行数 v_sqlvarchar(2000);--动态SQL变量begin --读取表中的列 forcolin(selectcolumn_namefromuser_tab_columnswheretable_name='TEMP')loop colname:=col.column_name;--替换换行符chr(10) v_sql:='selectcount(1)fromtempwhereinstr('||colname|| ',chr(10))>0';EXECUTEIMMEDIATEV_SQLintocnt;ifcnt>0then v_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>0then v_sql:='updatetempset'||colname||'=trim(replace('||colname|| ',chr(13),chr(13))>0';EXECUTEIMMEDIATEV_SQL;commit; endif;--替换'|'chr(124)为'*'chr(42) v_sql:='selectcount(1)fromtempwhereinstr('||colname|| ',chr(124))>0';EXECUTEIMMEDIATEV_SQLintocnt;ifcnt>0then v_sql:='updatetempset'||colname||'=replace('||colname|| ',chr(124),chr(42))'||'whereinstr('||colname|| ',chr(124))>0';EXECUTEIMMEDIATEV_SQL;commit; endif;endloop;endPROC_test;/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |