Unix Technical Forum

Re: Table function support

This is a discussion on Re: Table function support within the Pgsql Patches forums, part of the PostgreSQL category; --> Hello I searched some notes about this topic. I didn't find any usefull sample. Lot of samples are about ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 09:56 AM
Pavel Stehule
 
Posts: n/a
Default Re: Table function support

Hello

I searched some notes about this topic. I didn't find any usefull sample.
Lot of samples are about external stored procedures and others about using
table expression like

create function foo(i1)
returns table (a1 int)
as
return table(select a1 from tab)

isn't clear if table attributes are related to output variables, but nobody
join it together.

SQL/PSM sample:
create function accounts_of (customer_name char(20))
returns table ( account_number char(10),
branch_name char(15)
balance numeric(12,2))
return table
(select account_number, branch_name, balance
from account A
where exists (
select *
from depositor D
where D.customer_name = accounts_of.customer_name
and D.account_number = A.account_number ))


correct calling of it is:
select *
from table (accounts_of (‘Smith’))

next sample:
CREATE FUNCTION filmtyp (art CHAR(2))
RETURNS TABLE (titel VARCHAR(75), jahr INTEGER)
LANGUAGE SQL
READS SQL DATA
NO EXTERNAL ACTION
DETERMINISTIC
RETURN
SELECT titel, jahr
FROM film
WHERE film.art = filmtyp.art


Table functions are named as parametrised views too. I don't thing using OUT
variables is good idea, because you will have problems with colum's names,
which is problem for plpgsql.

http://www.wiscorp.com/SQL2003Features.pdf
http://wwwdvs.informatik.uni-kl.de/c...t_Behavior.pdf

Regards
Pavel Stehule



>From: Tom Lane <tgl@sss.pgh.pa.us>
>To: "Pavel Stehule" <pavel.stehule@hotmail.com>
>CC: pgsql-patches@postgresql.org
>Subject: Re: [PATCHES] Table function support Date: Tue, 10 Apr 2007
>18:17:14 -0400
>
>"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
> > this patch allows using SQL2003 syntax for set returning functions. It

>is
> > based on using new type of argmode - PROARGMODE_TABLE.

>
>I've been looking at this, and my feeling is that we should drop the
>PROARGMODE_TABLE business and just define RETURNS TABLE(x int, y int)
>as exactly equivalent to RETURNS SETOF RECORD with x and y treated as
>OUT parameters. There isn't any advantage to distinguishing the cases
>that outweighs breaking client code that looks at pg_proc.proargmodes.
>I don't believe that the SQL spec prevents us from exposing those
>parameter names to PL functions, especially since none of our PLs are
>in the standard at all.
>
> regards, tom lane


__________________________________________________ _______________
Najdete si svou lasku a nove pratele na Match.com. http://www.msn.cz/


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:36 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com