Operating System - HP-UX
1748089 Members
4978 Online
108758 Solutions
New Discussion юеВ

Re: how to insert a ' character

 
SOLVED
Go to solution
Adrian_72
Advisor

how to insert a ' character

I need to construct a dinamic query with ' character. for example

how to obtain a next result:

create user 'goviedo';

I execute the next query :

SQL> select 'create user ' ' ' '||username||';' from dba_users;
ERROR:
ORA-01756: quoted string not properly terminated

my problem is how I can insert a ' character in my select?

Thanks
3 REPLIES 3
Fred Ruffet
Honored Contributor
Solution

Re: how to insert a ' character

what you need is double ' to put a single ' in string and a single ' to close/open your string. So, it gives something like this :
select 'create user '''||username||''';'
from dba_users;

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Jean-Luc Oudart
Honored Contributor

Re: how to insert a ' character

Try
select 'create user''' || username || ''';' from dba_users

Regards,
Jean-Luc
fiat lux
Yogeeraj_1
Honored Contributor

Re: how to insert a ' character

hi,

please allow me to contribute the new functionality in 10g:

select q'|It's great|', q'#it's great#', q'xit's great!x'
from dual

Q'|IT'SGREAT Q'#IT'SGREAT Q'XIT'SGREAT
------------ ------------ ------------
It's great it's great it's great!

if the literal begins with q -- then the next two characters represent the "begin of string" marker and the reverse of those two represent the "end of string" marker.

hope this helps too!
regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)