Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Concatenate with COALESCE

511188Jun 13 2006 — edited Jun 13 2006
Hi, I am an Oracle newbie and my PL/SQL is somewhat lacking. I would like to be able to return a string value that is a comma separated list of ids. I have been able to do this in T-SQL and have included the query I would like to replicate at the end of the post.

@userId is a parameter passed into the procedure from the application.

Any guidance on this would be most helpful.

Thanks for taking the time to look.

Matt

------------------------------------------------------

declare @apps as varchar(2000)

SELECT @apps = COALESCE(@apps + ', ', '') +
RTRIM(CAST([App_id] AS varchar(10)))
FROM [Admins]
WHERE (pcode = @userId)

select @apps as apps


This returns something like: 5,10,12 etc.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 11 2006
Added on Jun 13 2006
1 comment
758 views