Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Selecting Values in a Column as a Single Variable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-27-03, 11:25
dineshyadav dineshyadav is offline
Registered User
 
Join Date: May 2002
Posts: 29
Selecting Values in a Column as a Single Variable

Hi,

I have a table which has three Columns Col A, Col B, COl C. I want to select values in Column Col A into a Single Variable variable Val with a delimiter of my choice. I want to do this without opening a Cursor the reason being in the stored procedure where I want this query inserted as I already have two cursors open and I don't want a third cursor in the procedure. The database version I am using is 8i. I iniitally had the same problem in MS SQL and it was sorted using COALESCE. Do we have any equivalent in Oracle.
Please help me.

Regards
Dinesh
Reply With Quote
  #2 (permalink)  
Old 05-27-03, 11:36
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: Selecting Values in a Column as a Single Variable

Quote:
Originally posted by dineshyadav
Hi,

I have a table which has three Columns Col A, Col B, COl C. I want to select values in Column Col A into a Single Variable variable Val with a delimiter of my choice. I want to do this without opening a Cursor the reason being in the stored procedure where I want this query inserted as I already have two cursors open and I don't want a third cursor in the procedure. The database version I am using is 8i. I iniitally had the same problem in MS SQL and it was sorted using COALESCE. Do we have any equivalent in Oracle.
Please help me.

Regards
Dinesh

Try this, if your query will return just one row:

Code:
declare delim varchar2(1) := '|'; var varchar2(100); begin select a||delim||b||delim||c into var from table where ...; end;

Not sure what your thinking is about not opening a third cursor. However you select data, a cursor is always used. It's just that sometimes the cursor is implicit so you don't have to name it or open/close it explicitly.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On