Re: JOIN results of refcursor functions

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: milan(dot)opa(at)gmail(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: JOIN results of refcursor functions
Date: 2008-12-02 05:58:58
Message-ID: 162867790812012158w43b0c956ue569edd536290499@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 | 10
juku | 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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Shane Ambler 2008-12-02 16:30:34 Re: how to update 400 000 register not at the same time?
Previous Message hdhgdh mjhff 2008-12-02 02:57:04 DIVISION with Group By