Re: Return dynamic columns of a temporary table - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Return dynamic columns of a temporary table
Date
Msg-id CAFj8pRCUSC64b5FsrU3g5-fDBVA+qkFsy5dXJqL1wbX0wC=GPg@mail.gmail.com
Whole thread Raw
In response to Return dynamic columns of a temporary table  (clear chan <clear.cas.1140@gmail.com>)
List pgsql-general
Hello

2012/10/4 clear chan <clear.cas.1140@gmail.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

>


pgsql-general by date:

Previous
From: David Fetter
Date:
Subject: Re: Moving from Java 1.5 to Java 1.6
Next
From: Shaun Thomas
Date:
Subject: Re: Moving from Java 1.5 to Java 1.6