Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Embedding quotes in strings

GusoraAug 16 2013 — edited Aug 17 2013

In the code segment below (hope it appears right) I can understand the use of single quotes in the first two examples but in the third example below I had to use double quotes around the word - Today's - and I not sure I understand why?!

I'm aware of the rules ...

If you want a single quote to appear in the middle of a string add another single quote to it.

If you want a single quote to appear at the beginning or end of a string add 2 single quotes to it.

If you want a single quote to appear on its own add 3 single quotes to it.

I'm hoping someone can shed some light on this for me.

SQL> select 'This isn''t' from dual;

'THISISN''

----------

This isn't



SQL> select to_number('34@456#789', '999G999D999', 'nls_numeric_characters=''#@'' ') from dual;

TO_NUMBER('34@456#789','999G999D999','NLS_NUMERIC_CHARACTERS=''#@''')

---------------------------------------------------------------------

                                                            34456.789



SQL> select to_char(sysdate, 'fm"Today''s" ddth Month YYYY') from dual;

TO_CHAR(SYSDATE,'FM"TODAY''S"DDTHMONTHYYYY')

------------------------------------------------------

Today's 16th August 2013

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2013
Added on Aug 16 2013
12 comments
26,807 views