Concatenate with COALESCE
511188Jun 13 2006 — edited Jun 13 2006Hi, 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.