Re: plpgsql returning resultset - Mailing list pgsql-general

From Thomas Finneid
Subject Re: plpgsql returning resultset
Date
Msg-id 48BDA83E.4010603@ifi.uio.no
Whole thread Raw
In response to Re: plpgsql returning resultset  (Raymond O'Donnell <rod@iol.ie>)
Responses Re: plpgsql returning resultset
Re: plpgsql returning resultset
List 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



pgsql-general by date:

Previous
From: "Kynn Jones"
Date:
Subject: How to create a case-insensitive unique constraint?
Next
From: jose lawrence
Date:
Subject: Conflict between MVCC and manual locking