Home » SQL & PL/SQL » SQL & PL/SQL » Output a column
Output a column [message #10647] Fri, 06 February 2004 12:40 Go to next message
Tony Diaz
Messages: 1
Registered: February 2004
Junior Member
How do I out put a column in sql that is in double quotes? 
Re: Output a column [message #10654 is a reply to message #10647] Sun, 08 February 2004 05:13 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
It is a really bad idea to create column names within double quotes, because then you have to enclose that name in double quotes in the same case as you created it everywhere that you use it. However, sometimes third party applications create them this way and you are stuck with it. Please see the example below for how to use such a column.

scott@ORA92> CREATE TABLE your_table
  2    ("Some column" VARCHAR2(30))
  3  /

Table created.

scott@ORA92> INSERT INTO your_table ("Some column")
  2  VALUES ('value for some column')
  3  /

1 row created.

scott@ORA92> SELECT "Some column"
  2  FROM   your_table
  3  /

Some column
------------------------------
value for some column
Re: Output a column [message #10655 is a reply to message #10654] Sun, 08 February 2004 05:19 Go to previous message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
It just occurred to me that you might have meant something different. If you want to output the column value with double quotes around it, you can do so by concatenating the quotes on either side. If that is what you want, then please see the examples below, with and without the double quotes.

scott@ORA92> SELECT dname
  2  FROM   dept
  3  /

DNAME
--------------
ACCOUNTING
RESEARCH
SALES
OPERATIONS

scott@ORA92> SELECT '"' || dname || '"' AS dname
  2  FROM   dept
  3  /

DNAME
----------------
"ACCOUNTING"
"RESEARCH"
"SALES"
"OPERATIONS"
Previous Topic: SQLPLUS
Next Topic: PL/SQL PROBLEM
Goto Forum:
  


Current Time: Fri Apr 26 23:24:16 CDT 2024