Hi,

I have a i/p as '1,2,3,4' which comes as a string and i would the o/p of the funtion as
1
2
3
4

something like it.


The function i have written is :-

create or replace function f_c(text) returns int as '
declare ip alias for $1;
len int; pos int; sub int;
begin
len := length(ip);
pos := position('','' in ip);
sub := cast(substr(ip,1,pos-1) as int);
return sub;
end;'language plpgsql;


select f_c('1,2,3); gives the result 1.

How should i get the result :-

1
2
3

Cursors can be used but how ?, if not what should be used ? Is there any way to use set of ? if yes , how /

Thanks, Pls reply as soon as possible.