Re: How to fix set-valued function called in contextthat cannot accept a set in earlier versions
| От | Andrus |
|---|---|
| Тема | Re: How to fix set-valued function called in contextthat cannot accept a set in earlier versions |
| Дата | |
| Msg-id | E9166C136EEA496085389F56CE846800@andrusnotebook обсуждение исходный текст |
| Ответ на | Re: How to fix set-valued function called in context that cannot accept a set in earlier versions (hubert depesz lubaczewski <depesz@depesz.com>) |
| Ответы |
Re: How to fix set-valued function called in contextthat cannot accept a set in earlier versions
|
| Список | pgsql-general |
Than you.
> remove begin and end from above function.
I tried code belwo in 8.3 but got error
ERROR: column "line" does not exist
LINE 29: select * from wordwrap(line,linelen);
Andrus.
CREATE OR REPLACE FUNCTION wordwrap(line text, linelen integer)
RETURNS SETOF text as $$
DECLARE
words text[] := string_to_array(line,' ');
i integer;
res text:='';
BEGIN
if trim(line)='' then
return next '';
return;
end if;
for i IN 1 .. array_upper(words,1) LOOP
if length(res)+length(words[i]) > linelen THEN
return next res;
res := '';
END IF ;
if res<>'' then
res := res || ' ';
end if;
res := res || words[i];
end loop;
return next res;
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION wordwrap83(line text, linelen integer)
RETURNS SETOF text as $$
select * from wordwrap(line,linelen);
$$ LANGUAGE sql;
select wordwrap83('fdgdf',10)
В списке pgsql-general по дате отправления: