Re: plpgsql returning resultset

From: Thomas Finneid <tfinneid(at)student(dot)matnat(dot)uio(dot)no>
To: rod(at)iol(dot)ie
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql returning resultset
Date: 2008-09-02 20:55:26
Message-ID: 48BDA83E.4010603@ifi.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Raymond O'Donnell wrote:

> Can you show us more of your code?

I figured out how to make it work when using "for" instead of "with".

Here is the code and the error message. I couldnt find anything in the
documentation about "with" but I did find something about "for" which I
managed to make work. In any case here is the code for the "with" code:

create or replace function get_profile() returns setof tableA as
$$
declare
val_list tableA%rowtype;
begin

with val_list in
select * from tableA
do
loop
return next val_list;
end loop;

return;
end;
$$ language 'plpgsql';

the error message is:

psql:functions.sql:116: ERROR: syntax error at or near "with $1"
LINE 1: with $1 in select * from attribute_values_part_seq_1_ff_5 ...
^
QUERY: with $1 in select * from attribute_values_part_seq_1_ff_5 do
loop return next $1
CONTEXT: SQL statement in PL/PgSQL function "get_profile" near line 10

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Wilson 2008-09-02 21:11:21 Re: Foreign Key normalization question
Previous Message Kynn Jones 2008-09-02 20:46:21 How to create a case-insensitive unique constraint?