Help - Search - Members - Calendar
Full Version: Problem in Query
Oracle DBA Forums > Oracle > Oracle Forum
Hi All ,

i have a table with one column .... in this table there are 10 rows.....i want to give result like this in one variable...(1,2,3,4,5,6,7,8,9,10) point is how to write select query..when this is give me this type of result....i write a procedure

CREATE OR REPLACE Procedure Getlist() as
list1 VARCHAR2(8000) default '';
select COALESCE ( nullif(list1,'') || ',','') || ids Into list1 from tmpIDS;
select NVL(list1,'') into list1 from dual;

but this procedure give me error....(ORA-01422: exact fetch returns more than requested number of rows)

Please Help me

Thanks in Advance
Why would you do this in PL/SQL anyway? What you are looking for is pivot, row to column, etc. Google it and pick one of the examples that best suits your needs.
u can't get result from table into (one) variable
(too many row is not exception from procedure, but from you select)

U may try samething of a:

list1 varchar2(200):='';
ind number:=0;
for line in ( select ids from tmpids order by ids) loop
if ind=1 then list1:=list1||','; end if; ind:=1;
end loop;
"i want to give result like this in one variable...(1,2,3,4,5,6,7,8,9,10)......"


Is this what you want, displaying multiple columns on one row?

If you want to put the result into a single variable, you could concatenate it on output:

select "("||col1||','||col2||','col3||")" bigfield . . . . .
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2016 Invision Power Services, Inc.