By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,504 Members | 1,903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,504 IT Pros & Developers. It's quick & easy.

Suppressing newline during a SELECT returning multiple rows

P: n/a
Is there any way for Oracle (using standard SQL rather than PL/SQL) to
suppress the newline character when returning a list of rows.

For example, if I have a table EMP with several records. When I issue
the statement:

SELECT name FROM emp

I would like to get a single row output back comprising the following:

"john, james, jenny, jill, benny"

in other words, all names separated by the a comma followed by space.

Many thanks in advance for you help.

Shuaib
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
sr******@yahoo.com (Shuaib) wrote in message news:<12**************************@posting.google. com>...
Is there any way for Oracle (using standard SQL rather than PL/SQL) to
by that I assume you mean using SQL*Plus versus some other ORACLE
client program (such as an ODBC client like ACCESS)?
suppress the newline character when returning a list of rows.
I do not think you can totally suppress it. In SQL*Plus there is a
option to set the line size. Look up the options in the SET command.
There is also an option to define the record separator character,
IIRC. If so, it too is an option to the SET command.
I would like to get a single row output back comprising the following:

"john, james, jenny, jill, benny"

in other words, all names separated by the a comma followed by space.

Many thanks in advance for you help.

Shuaib


The manual is your friend. (You likely just needed the right words to
look it up in the index, right?)

HTH,
ed
Jul 19 '05 #2

P: n/a
ed********@magicinterface.com (Ed prochak) wrote in message news:<4b**************************@posting.google. com>...
sr******@yahoo.com (Shuaib) wrote in message news:<12**************************@posting.google. com>...
Is there any way for Oracle (using standard SQL rather than PL/SQL) to


by that I assume you mean using SQL*Plus versus some other ORACLE
client program (such as an ODBC client like ACCESS)?
suppress the newline character when returning a list of rows.


I do not think you can totally suppress it. In SQL*Plus there is a
option to set the line size. Look up the options in the SET command.
There is also an option to define the record separator character,
IIRC. If so, it too is an option to the SET command.
I would like to get a single row output back comprising the following:

"john, james, jenny, jill, benny"

in other words, all names separated by the a comma followed by space.

Many thanks in advance for you help.

Shuaib


The manual is your friend. (You likely just needed the right words to
look it up in the index, right?)

HTH,
ed


Shuaib, what you really asking to do is to convert rows into columns.
Check the group archives looking for "pivot tables". There was a
couple of posts under the comp.databases.oracle.misc or server board
just yesterday on this subject. You can search the group archives via
http://groups.google.com if your normal newreader does not provide
access.

You can also check the asktom site: http://asktom.oracle.com. It has
writeup for performing this task using object types.

HTH -- Mark D Powell --
Jul 19 '05 #3

P: 1
When I issue the statement:

SELECT name FROM emp

I would like to get a single row output back comprising the following:

"john, james, jenny, jill, benny"

in other words, all names separated by the a comma followed by space.
I've been searching all over the net trying to find a resolution to this very issue and can't find one that doesn't involve modifying the database with custom types or stored procedures. I'm running Oracle 9i, which is supposed to have a bunch of new string handling functions in it, but I can't find anything that tells me how to do something just like this using built-in functions.

T/SQL has this handy thing called "LIST" that evidently does exactly this. Oracle doesn't seem to have anything similar, at least not that I can find. Ideas?

thx

JD
Jul 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.