Re: Passing tables as parameter

From: gianpaolo <gianpaolo(at)preciso(dot)net>
To: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Passing tables as parameter
Date: 2001-01-07 22:49:07
Message-ID: 01010723490700.12109@simpson.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday 07 January 2001 02:23, Robert B. Easter wrote:
> Can I see your function that tried to do it? Pg 7.1 beta has a new EXECUTE
> statement for PL/pgSQL that allows execution of a query string that can be
> created dynamically (see the development docs at www.postgresql.org). It
> might be relevant to your problem.

Thanks for your attention
I have this function:
CREATE FUNCTION free_id() RETURNS int4
as 'SELECT id from pers_id where flag=0'
LANGUAGE 'sql';

I have to duplicate it 4 o 5 times, so I thougth to write something like
CREATE FUNCTION free_id(text) RETURNS int4
as 'SELECT id from $1 where flag=0'
LANGUAGE 'sql';

to specify different tables when I call the function.
I tried to put different things from '(text)' after the function name, but it
gives me always an error. I tried also to use the other syntax in select
(which I saw in the manual is preferred in functions):

CREATE FUNCTION free_id(text) RETURNS int4
as 'SELECT $1.id where flag=0'
LANGUAGE 'sql';

but I got nothing good...
any idea? (it's a matter of theory, 'cause I don't care to write down 1 or 4
functions...)

have a good day
--
gianpaolo racca
gianpaolo(at)preciso(dot)net
http://www.preciso.net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Uro Gruber 2001-01-08 00:36:21 Help with JOINING 3 tables
Previous Message Tom Lane 2001-01-07 20:00:50 Re: Index on Date_Trunc