473,787 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suppressing newline during a SELECT returning multiple rows

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
3 10774
sr******@yahoo. com (Shuaib) wrote in message news:<12******* *************** ****@posting.go ogle.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
ed********@magi cinterface.com (Ed prochak) wrote in message news:<4b******* *************** ****@posting.go ogle.com>...
sr******@yahoo. com (Shuaib) wrote in message news:<12******* *************** ****@posting.go ogle.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
jdray
1 New Member
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5211
by: Monisha | last post by:
Hi, I need to get a list of columns and corresponding datatypes for the given table name. I am using the query: select a.name, b.type_name from syscolumns a,
9
10773
by: Rowland Hills | last post by:
I have a table which is returning inconsistent results when I query it! In query analyzer: If I do "SELECT * FROM TABLE_NAME" I get no rows returned. If I do "SELECT COL1, COL2 FROM TABLE_NAME" I get 4 rows returned. In Enterprise manager:
22
3725
by: Christopher Murtagh | last post by:
Greetings, I'm trying to write a pl/perl function that will return multiple rows. I've looked all over the web and only found vague references as to how to do this (some said it was possible, and some said it wasn't but it was for older versions of Postgres). Basically I would *love* to be able to do something like this: SELECT some_id
6
4692
by: ronchese | last post by:
Hi. I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working! In one of my tests, I have a datatable with 1 row and a field containing the following value (extracted from Immediate Window): ?dtbSample.Rows(0).Item("COM_STARTDATE") #5/8/2006 9:00:00 AM# {Date} Date: #5/8/2006 9:00:00 AM# (for better understand, consider this date as '2006/05/08')
2
5674
by: John Salerno | last post by:
If I read a string that contains a newline character(s) into a variable, then write that variable to a file, how can I retain those newline characters so that the string remains on one line rather than spans multiple lines? Example: In a CGI script, I'm reading the address field from an HTML form. Almost always the person will press ENTER so they can enter a second or third line. If I then want to write all the field values of this form...
4
7120
by: Aryan | last post by:
Hi, I am having problem with DataTable.Select() method. I am using ASP.NET 2.0. I have DataSet which reads data from XML file using DataSet.ReadXML(). Now this dataset has various datatable, created by XML file. I am taking one of the datatable from this dataset and want to filter on that datatable using Select() method. Now here the problem start, like when I pass multiple "And" clause in
0
1342
by: =?Utf-8?B?U3RldmU=?= | last post by:
C# I have a datagrid, and the users are able to select multiple rows and perform an action. This works fine, as I get the rows selected using something like this: CurrencyManager xCM = (CurrencyManager)dgWork.BindingContext; DataView xDV = (DataView)xCM.List;
3
2970
by: weird0 | last post by:
The given should return A,B that is two rows because both accountnames A and B have the same user_Id=1 but it is only returning A when I performed the op. MessageBox.Show("AccountNames:" + Object.ToString() ); public Object GetAccountNames(string User_Id) { //string AccountNames; Object AccountNames;
2
216
by: Shuaib | last post by:
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:
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.