DECLARE @EmployeeList varchar(5000) SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') + CAST(ltrim(rtrim(emp_id )) AS varchar(20)) FROM employee SELECT @EmployeeList
I need results in Oracle with PL/SQL as well.
Requires Free Membership to View
DECLARE
result_set varchar2(4000);
cursor c1 is select emd_id from employee;
BEGIN
FOR c1rec in c1 LOOP
result_set := result_set || ',' || c1rec.emp_id;
END LOOP;
dbms_output.put_line(ltrim(result_set, ','));
END;
This was first published in March 2004

Join the conversationComment
Share
Comments
Results
Contribute to the conversation