composite types

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема composite types
Дата
Msg-id 20040420174130.2cace9ea@stige.webthatworks.it
обсуждение исходный текст
Ответы Re: composite types  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Re: composite types  (Steve Manes <smanes@magpie.com>)
Список pgsql-general
I'd like to compute some "row like" results and return them from a
function (and pass the result to PHP[*]).

Well I've read about composite type but all the references I've seen
are about coding in C. That's not the way I'd like to follow by now.

I was expecting to declare composite types in plpsql or plain sql in a
similar way I'd do in C/C++ with struct/class.

I've found this
http://archives.postgresql.org/pgsql-general/2001-03/msg01459.php
but I'd like to avoid to declare a table just for a temp.

pseudocode follow

declare struct pippo(
    integer a;
    varchar(8) b;
)

create or replace function functiontest( ) returns pippo
as '
declare
    integer tempa;
    varchar(8) tempb;

begin
    /*
    do stuff to fill tempa and tempb
    */
    return (tempa,tempb)
end
' language plpgsql;

[*] I guess that to access the result of such a function
...
$SQLResult = pg_exec( $SQLConn, "SELECT functiontest( );" );
$SQLData = pg_fetch_row( $SQLResult, 0 );
should be enough...

thx



В списке pgsql-general по дате отправления:

Предыдущее
От: Alan Graham
Дата:
Сообщение: Re: Anyone using pgreplicator?
Следующее
От: Joe Conway
Дата:
Сообщение: Re: [OT] Tom's/Marc's spam filters?