Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is CHR code for single quote ' in oracle?

What is CHR code for single quote (') in oracle?
I am generating update statements ATM for tables without PKs, and Regex replacing some special characters.

select 'UPDATE QUESTION SET questiontypeid = '||questiontypeid||', questiontext = '''||questiontext||''', questiondescription = '''||questiondescription||''', productid = '||productid||', mandatory = '||CASE WHEN mandatory IS NULL THEN 'NULL' ELSE to_char(mandatory) END ||', displayorder = '||displayorder||', minvalue = '||CASE WHEN minvalue IS NULL THEN 'NULL' ELSE to_char(minvalue) END||', maxvalue = '||CASE WHEN maxvalue IS NULL THEN 'NULL' ELSE to_char(maxvalue) END||', parentid = '||CASE WHEN parentid IS NULL THEN 'NULL' ELSE to_char(parentid) END||', questioncategoryid = '||questioncategoryid||', isasset = '||CASE WHEN isasset IS NULL THEN 'NULL' ELSE to_char(isasset) END||', ISTHUNDERHEADONLY = '||CASE WHEN ISTHUNDERHEADONLY IS NULL THEN 'NULL' ELSE to_char(ISTHUNDERHEADONLY) END||', QCODE = '''||QCODE||''' WHERE QUESTIONID = '||QUESTIONID from (
(select * from question where questionid not in
(select t.questionid from question t
full join [email protected] d on t.questionid = d.questionid 
where t.questiontypeid <> d.questiontypeid
or t.questiontext <> d.questiontext
or t.questiondescription <> d.questiondescription
or t.productid <> d.productid
or t.mandatory <> d.mandatory
or t.displayorder <> d.displayorder
or t.minvalue <> d.minvalue
or t.maxvalue <> d.maxvalue
or t.parentid <> d.parentid
or t.questioncategoryid <> d.questioncategoryid
or t.isasset <> d.isasset))
)
like image 390
Matas Vaitkevicius Avatar asked Dec 09 '25 07:12

Matas Vaitkevicius


2 Answers

Let's see the ASCII value :

SQL> select ascii('''') from dual;

ASCII('''')
-----------
         39

Or, to avoid multiple single-quotation marks, using literal quote technique :

SQL> select ascii(q'[']') from dual;

ASCII(Q'[']')
-------------
           39

Let's confirm :

SQL> select chr(39) from dual;

C
-
'

SQL>
like image 122
Lalit Kumar B Avatar answered Dec 12 '25 06:12

Lalit Kumar B


Thanks to @a_horse_with_no_name:

There is nothing special about ' in Oracle. It's the standard ASCII value.

Answer is : CHR(39)

like image 21
Matas Vaitkevicius Avatar answered Dec 12 '25 05:12

Matas Vaitkevicius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!