View Single Post

   
  #1 (permalink)  
Old 04-19-2008, 12:50 PM
Mike Plemmons
 
Posts: n/a
Default Question about functions

I have been looking through FAQs and the docs and I cannot seem to find the
answer to this question. If someone can point me to documentation I would
really appreciate it.

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
$$
DECLARE
myrec record;
BEGIN
FOR myrec IN SELECT * FROM tblStuff WHERE ides LIKE '%$1%' LOOP
RETURN NEXT myrec;
END LOOP;
RETURN;
END;
$$ LANGUAGE 'plpgsql';

Thanks so much for any insight you can give me!!!
Mike

Reply With Quote