Re:

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Jerzy Bialas <jbialas3(at)wp(dot)pl>
Subject: Re:
Date: 2009-09-26 20:45:51
Message-ID: 200909261345.51501.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Saturday 26 September 2009 1:10:20 pm Pavel Stehule wrote:
> Hello
>
> 2009/9/26 Adrian Klaver <aklaver(at)comcast(dot)net>:
> > On Friday 25 September 2009 9:52:09 am Pavel Stehule wrote:
> >> Hello
> >>
> >> this isn't possible now. All what you want are limited by SELECT
> >> statement in PostgreSQL. Simply PL knows only  SELECT statement and
> >> structure of result have to be strongly static - because it is based
> >> on static execution plan - it is determined before query start.
> >>
> >> Statement CALL isn't implemented yet.
> >>
> >> Regards
> >> Pavel Stehule
> >
> > I may be misinterpreting the docs section below, but I beg to differ.
> >
> > http://www.postgresql.org/docs/8.4/interactive/plpgsql-statements.html#PL
> >PGSQL-STATEMENTS-EXECUTING-DYN
>
> the sql for EXECUTE statement should be dynamic, but the structure of
> result have to be stable.
>
> Pavel
>

RECORD type, RETURN RECORD ?

38.3.4. Record Types

name RECORD;

Record variables are similar to row-type variables, but they have no predefined
structure. They take on the actual row structure of the row they are assigned
during a SELECT or FOR command. The substructure of a record variable can
change each time it is assigned to. A consequence of this is that until a
record variable is first assigned to, it has no substructure, and any attempt
to access a field in it will draw a run-time error.

Note that RECORD is not a true data type, only a placeholder. One should also
realize that when a PL/pgSQL function is declared to return type record, this
is not quite the same concept as a record variable, even though such a function
might use a record variable to hold its result. In both cases the actual row
structure is unknown when the function is written, but for a function returning
record the actual structure is determined when the calling query is parsed,
whereas a record variable can change its row structure on-the-fly.

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

  • Re: at 2009-09-26 20:10:20 from Pavel Stehule

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2009-09-26 20:57:32 Re: Column names in rowsets returned from function
Previous Message David Fetter 2009-09-26 20:23:49 Re: generic modelling of data models; enforcing constraints dynamically...