How to replace single-quote with double-quote in sql query - oracle 10g?
How can I replace single-quote (') with double-quote (") in sql query - oracle开发者_运维知识库 10g?
This should work:
UPDATE myTable
SET myField = REPLACE(myField, '''', '"');
You can use Ansi-codes as well, to make it more crystal what is happening:
SELECT someString
,replace(someString, Chr(39), Chr(34)) as replacedString
FROM (SELECT ' abc ' || Chr(39) || ' def ' as someString
FROM Dual)
39 is a single quote, 34 a double quote
If you have a variable in single quotes with an apostrophe e.g. 'John's Book', simply insert 2 apostrophes. i.e. 'John''s Book'. NOTE: Do NOT use a double quotation "
This should work:
UPDATE myTable
SET field = replace(your_string,Chr(39),Chr(39)||Chr(39));
Ten bucks says this thing is wide-open to SQL injection and the correct answer is to use parameterization.
精彩评论