Re: Question about functions

Поиск
Список
Период
Сортировка
Искать
От
Stewart Ben (RBAU/EQS4) *
Тема
Re: Question about functions
Дата
Msg-id
E253BDD7F008244585AEE87AF8F0224F116C7AE2@cl-mail01.au.bosch.com
Список
Дерево обсуждения
Re: Question about functions "Stewart Ben (RBAU/EQS4) *" <Ben.Stewart@au.bosch.com>
Mike,

> I am trying to run this function but the return is not 
> correct.  If I run the select statement from the psql command 
> line it works.  My guess is that the WHERE clause could be 
> causing the problem.  Then again, it may be how I am using 
> the FOR loop.  The ides column is of type TEXT.
> 
> CREATE OR REPLACE FUNCTION sp_description_search(varchar) 
> RETURNS varchar AS $$         -- <== Problem is here
> DECLARE
> myrec record;
> BEGIN
> FOR myrec IN SELECT * FROM tblStuff WHERE ides LIKE '%$1%' LOOP
> RETURN NEXT myrec;            -- <== Problem is here
> END LOOP;
> RETURN;
> END;
> $$ LANGUAGE 'plpgsql';

You need to declare this as a set-returning function if you're using
RETURN NEXT.

Best regards,

Ben Stewart

--
Robert Bosch (Australia) Pty. Ltd.
Engineering Quality Services, Student Software Engineer (RBAU/EQS4)
Locked Bag 66 - Clayton South, VIC 3169 - AUSTRALIA
mailto:ben.stewart@au.bosch.com
http://www.bosch.com.au/ 

В списке pgsql-sql по дате отправления
От: Mike Plemmons
Дата:
Сообщение: Question about functions
От: Richard Huxton
Дата:
Сообщение: Re: Question about functions
FAQ