Re: sql query with join and parameter in postgresql function - Mailing list pgsql-sql

From Michael Glaesemann
Subject Re: sql query with join and parameter in postgresql function
Date
Msg-id 4F60A32A-4819-11D8-B824-000A95C88220@myrealbox.com
Whole thread Raw
In response to sql query with join and parameter in postgresql function  ("Philippe Lang" <philippe.lang@attiksystem.ch>)
List 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



pgsql-sql by date:

Previous
From: "Philippe Lang"
Date:
Subject: sql query with join and parameter in postgresql function
Next
From: "Philippe Lang"
Date:
Subject: Re: sql query with join and parameter in postgresql function