From: Beth <bethg@cybernamix.com>
To: pgsql-sql@postgresql.org
Subject: Re: cannot create function that uses variable table name
Date: 20 Jan 2003 16:17:32 +1300
Message-ID: <1043032653.2163.116.camel@white> (raw)
As per Matthew Nuzum's post
My query is very similar...
I need sql functions to update the database. If I specify the filename
etc they work. BUT that leads to 6 functions which are exactly the same
apart from the file they update.
1) why can't I use a variable name and
2) could someone please point me towards some examples of EXECUTE if
thats the only way to do it?
my example is:
CREATE FUNCTION retire(varchar, varchar, int4) returns int4 AS'
BEGIN
UPDATE $1 SET "Retired" = 'true' WHERE $2 = $3;
SELECT (whatever to return the int4);
END;'
Language 'plpgsql';
which has: parse error at or near "true"
($1 is the filename, $2 is the fieldname, $3 is the fieldvalue and
"Retired" is a boolean field in each of the files)
Thanks
Beth
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bethg@cybernamix.com
Subject: Re: cannot create function that uses variable table name
In-Reply-To: <1043032653.2163.116.camel@white>
* 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