Re: sql query with join and parameter in postgresql function

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: "Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: sql query with join and parameter in postgresql function
Date: 2004-01-16 11:44:15
Message-ID: 4F60A32A-4819-11D8-B824-000A95C88220@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Jan 16, 2004, at 8:30 PM, Philippe Lang wrote:

> Hello,
>
> I'd like to write a function similar to that:
>
> ------------------------------------------------
> CREATE FUNCTION public.report_join_parameter(char(6))
> RETURNS ??? AS

<snip />

> Do I ***HAVE TO*** define a composite type for the columns my function
> is supposed to return?

As far as I know. It's not that hard.

CREATE TYPE report_join_type (
tableAfield1 <type>,
tableAfield2 <type>,
tableBfield1 <type>,
tableBfield2 <type>,
tableCfield1 <type>,
tableCfield2 <type>
);

> I thought a view would be more appropriate, but if I'm not wrong, a
> view
> does not accept any parameter as input...

But you can just define the view and select it with a WHERE clause with
your parameter, just like a normal table. Would that help?

Michael Glaesemann
grzm myrealbox com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Philippe Lang 2004-01-16 13:03:26 Re: sql query with join and parameter in postgresql function
Previous Message Christoph Haller 2004-01-16 11:34:44 Re: problem with function trigger