Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with formating 2

Status
Not open for further replies.

rogers42

Technical User
Mar 30, 2007
64
CA
Hi,

Sample Data:
============
AAAAA
BBBB
CCCC

Desired Output:
================
'AAAAA',
'BBBBB',
'CCCCC'

My query looks as follows

select '''||distinct(MAC_ADDR)||'','
from MAC;

The compiler keeps complaining about the strings being not properly terminated.

Can somebody please revise my query ?

Thanks in advance

rogers42
 
Rogers,

You are soooooo close:
Code:
select ''''||name||'''' from s_region;

''''||NAME||''''
----------------------
'North America'
'South America'
'Africa / Middle East'
'Asia'
'Europe'
'Australia'
Notice that the first and last characters of a literal (in Oracle) must be single quotes. Then, if you want to embed within a string literal a single quote, you must use two successive single quotes (apostrophes). Thus, if you want a string that contains one single quote, you achieve it with four successive single quotes.

Let us know if you have additional questions.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Thanks, this makes sense. However, the compiler is complaining about the "distinct" keyword

select ''''|| distinct(MAC_ADDR)||''','
from MAC;

ERROR at line 1:
ORA-00936: missing expression

Thanks

rogers42
 

Distinct is not a function, try:
Code:
select distinct ''''||MAC_ADDR|''','
  from MAC;
[3eyes]




----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top