Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group