Unix Technical Forum

Re: Question about functions

This is a discussion on Re: Question about functions within the pgsql Sql forums, part of the PostgreSQL category; --> Mike, > I am trying to run this function but the return is not > correct. If I run ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:50 AM
Stewart Ben
 
Posts: n/a
Default Re: Question about functions

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/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:11 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com