problem with plpgsql function - Mailing list pgsql-general

From Alex Guryanow
Subject problem with plpgsql function
Date
Msg-id 9651.000810@nlr.ru
Whole thread Raw
Responses Re: problem with plpgsql function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

I have a table "isbn" (postgres-7.0.2) with two columns:

   book_id int4
   isbn varchar(20)

I want to create a function that joins all isbn for specified book_id.
The code of this function is:

   CREATE FUNCTION all_isbn2( int4 ) RETURNS varchar AS 'DECLARE
   i isbn%ROWTYPE;
   res varchar;
   BEGIN res := "";
   FOR i IN SELECT * FROM isbn WHERE isbn.book_id = $1 LOOP
   res := res || i.isbn;
   END LOOP;
   RETURN res;
   END;' LANGUAGE 'plpgsql';

But when i execute the query

book=> select all_isbn2(1);

I receive the following error:

ERROR:  Attribute '' not found

What I'm doing wrong?

Regards,
Alex



pgsql-general by date:

Previous
From: Andreas Tille
Date:
Subject: Re: Migrating from MS SQL server
Next
From: Andreas Tille
Date:
Subject: pg_dump and restore