oracle SQL 替换智能引号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/663492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:57:38  来源:igfitidea点击:

SQL to replace smart quotes

sqloraclesmart-quotes

提问by GBa

Does anyone know a SQL command to replace MS Office smart quotes with their ASCII cousins? I'm using an oracle database and the fields are of type varchar2

有谁知道用他们的 ASCII 表兄弟替换 MS Office 智能引号的 SQL 命令?我使用的是 oracle 数据库,字段的类型是 varchar2

回答by Rich

update table set column = replace(replace(column, chr(147),'"'), chr(148), '"')

更新表集列=替换(替换(列,chr(147),'“'),chr(148),'“')

回答by erikkallen

REPLACE(REPLACE(str, '`', ''''), '′', '''')

Or am I missing your question?

或者我错过了你的问题?

回答by aberpaul

I have had a similar problem. For me after the quotes were stored in the database they appeared thus "?'".

我遇到了类似的问题。对我来说,在将引号存储在数据库中之后,它们会出现“?'”。

SELECT abstract FROM foo WHERE version = '1.0' and newscode = 'au20309';

Mae?'r ffordd gynaliadwy y mae bwyd yn cael ei dyfu, ei brynu a?'i baratoi ...

Mae?'r ffordd gynaliadwy y mae bwyd yn cael ei dyfu, ei brynu a?'i baratoi ...

This is how I replaced them. First find the ascii value for that unusual "?" character.

这就是我替换它们的方式。首先找到那个不寻常的“?”的ascii值。特点。

SELECT ascii('?') FROM DUAL; -- returns 50050

Then use the chr function to render the "?". The || function concatenate the two characters. The q function is useful to 'quote' the smart quote string..

然后使用 chr 函数渲染“?”。|| 函数连接两个字符。q 函数可用于“引用”智能引号字符串。

SELECT REPLACE(abstract,chr(50050) || q'#'#' , q'#'#') 
FROM foo 
WHERE version = '1.0' and newscode = 'au20309';

Mae'r ffordd gynaliadwy y mae bwyd yn cael ei dyfu, ei brynu a'i baratoi ...

Mae'r ffordd gynaliadwy y mae bwyd yn cael ei dyfu, ei brynu a'i baratoi ...

This worked just fine for me on our Oracle 10 system.

这在我们的 Oracle 10 系统上对我来说效果很好。

回答by David Aldridge

回答by cdonner

update table set column = replace( column, string_to_replace, [ replacement_string ] )