Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4EB17475E7B for ; Sun, 19 Jan 2003 22:20:06 -0500 (EST) Received: from mta203-rme.xtra.co.nz (mta203-rme.xtra.co.nz [210.86.15.146]) by postgresql.org (Postfix) with ESMTP id 03890475B8F for ; Sun, 19 Jan 2003 22:20:05 -0500 (EST) Received: from mta5-rme.xtra.co.nz ([210.86.15.142]) by mta203-rme.xtra.co.nz with ESMTP id <20030120032008.IPPJ1199.mta203-rme.xtra.co.nz@mta5-rme.xtra.co.nz> for ; Mon, 20 Jan 2003 16:20:08 +1300 Received: from bethg.akl.cybernamix.net ([210.54.242.7]) by mta5-rme.xtra.co.nz with ESMTP id <20030120032007.GDLN18554.mta5-rme.xtra.co.nz@bethg.akl.cybernamix.net> for ; Mon, 20 Jan 2003 16:20:07 +1300 Subject: Re: cannot create function that uses variable table name From: Beth To: pgsql-sql@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8-3mdk Date: 20 Jan 2003 16:17:32 +1300 Message-Id: <1043032653.2163.116.camel@white> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/369 X-Sequence-Number: 11234 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