Re: Return dynamic columns of a temporary table

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: clear chan <clear(dot)cas(dot)1140(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Return dynamic columns of a temporary table
Date: 2012-10-04 15:39:21
Message-ID: CAFj8pRCUSC64b5FsrU3g5-fDBVA+qkFsy5dXJqL1wbX0wC=GPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2012/10/4 clear chan <clear(dot)cas(dot)1140(at)gmail(dot)com>:
> Hi, i am new to postresql and have been trying to convert some of our mssql
> procedures into postresql functions. What i have been trying to do is to
> somehow return a temporary table with dynamic columns. Is it possible?
>

it is possible, but usually it is not, what you want

CREATE OR REPLACE FUNCTION foo()
RETURNS SETOF RECORD AS $$
SELECT * FROM temptab;
$$ LANGUAGE sql;

but you have to specify columns in query

SELECT * FROM foo() (a int, b int, c int);

A style of PostgreSQL stored procedures is significantly different
than MSSQL - it is more close to Oracle.

Regards

Pavel Stehule

>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaun Thomas 2012-10-04 15:45:43 Re: Moving from Java 1.5 to Java 1.6
Previous Message David Fetter 2012-10-04 15:13:59 Re: Moving from Java 1.5 to Java 1.6