pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Philippe Lang <philippe.lang@attiksystem.ch>
To: pgsql-sql@postgresql.org
Subject: sql query with join and parameter in postgresql function
Date: Fri, 16 Jan 2004 12:30:56 +0100
Message-ID: <6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch> (raw)

Hello,

I'd like to write a function similar to that:

------------------------------------------------
CREATE FUNCTION public.report_join_parameter(char(6))
  RETURNS ??? AS
'
SELECT

tableA.field1,
tableA.field2,
tableB.field1,
tableB.field2,
tableC.field1,
tableC.field2,

FROM tableA

INNER JOIN tableB
ON tableA.pk = tableB.fk

INNER JOIN tableC
ON tableB.pk = tableC.fk

WHERE tableC.field3= 0
AND tableB.field1= $1
'
  LANGUAGE 'sql' VOLATILE;
------------------------------------------------

Do I ***HAVE TO*** define a composite type for the columns my function
is supposed to return? Isn't there a simpler method, that could allow me
to avoid this extra work?

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

Thanks!

Philippe



view thread (3+ messages)  latest in thread

Message-ID: <6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch>
Permalink:  ../6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch/
Also on:    postgresql.org/message-id/6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: philippe.lang@attiksystem.ch
  Subject: Re: sql query with join and parameter in postgresql function
  In-Reply-To: <6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch>
  References: <6C0CF58A187DA5479245E0830AF84F4208018E@poweredge.attiksystem.ch>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox