Re: JOIN results of refcursor functions - Mailing list pgsql-sql

From Pavel Stehule
Subject Re: JOIN results of refcursor functions
Date
Msg-id 162867790812012158w43b0c956ue569edd536290499@mail.gmail.com
Whole thread Raw
In response to Re: JOIN results of refcursor functions  (Milan Oparnica <milan.opa@gmail.com>)
Responses Re: JOIN results of refcursor functions  (Milan Oparnica <milan.opa@gmail.com>)
List pgsql-sql
>
> Then I've tried:
>
> CREATE FUNCTION foo(insklid int, out sklid int, out elid INT) RETURNS SETOF
> record AS $$
> BEGIN
>    RETURN QUERY SELECT sklid,elid FROM skladkol;
>    RETURN;
> END;
> $$ LANGUAGE plpgsql;

know bug :( - your variable names are in collision with column names.
You have to protect self - use prefixes for variables

postgres=# create table a(a varchar, b int);
CREATE TABLE
postgres=# insert into a values('kuku',10),('juku',20);
INSERT 0 2
postgres=# create function f(out _a varchar, out _b integer) returns
setof record as $$begin return query select * from a; return; end; $$
language plpgsql;
CREATE FUNCTION
postgres=# select * from f(); _a  | _b
------+----kuku | 10juku | 20
(2 rows)


regards
Pavel Stehule


>
> but it returns 5498 rows (which is exact number of rows in that table) but
> of NULL values. WHAT AM I DOING WRONG ?  :(((
>
> I'm using EMS Manager 2007 Lite for PostgreSQL. That shouldn't be a problem,
> right ?
>
> Regards,
>
> Milan Oparnica
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


pgsql-sql by date:

Previous
From: "hdhgdh mjhff"
Date:
Subject: DIVISION with Group By
Next
From: Shane Ambler
Date:
Subject: Re: how to update 400 000 register not at the same time?