Oracle version: 11.2.0.2
create table test_tab (col1 varchar2(15));
insert into test_tab values ('YELLOW');
insert into test_tab values ('GREEN');
insert into test_tab values ('RED');
insert into test_tab values ('BLUE');
commit;
SQL> select * from test_tab;
COL1
---------------
YELLOW
GREEN
RED
BLUE
I would like the values of the above table to be printed with
a single quote surrounding them followed by a commma and a space then right paranthesis.
Expected output 1 :
Colours are ('YELLOW', )
Colours are ('GREEN', )
Colours are ('RED', )
Colours are ('BLUE', )
Related question:
From googling , I gather that , to escape a single quote, just add another one to it. But my following attempts have failed.
For the above requirement , I was doing some experiments to get at least the following printed
Expected output 2:
My car is 'white'
This is what i Tried
SQL> select 'My car is '''white from dual;
WHITE
-----------
My car is '
SQL> select 'My car is ''white'' from dual;
ERROR:
ORA-01756: quoted string not properly terminated
SQL> select 'My car is '''white'' from dual;
select 'My car is '''white'' from dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
SQL> select 'My car is '''white''' from dual;
ERROR:
ORA-01756: quoted string not properly terminated