Received: from linux.stuco.uni-klu.ac.at (IDENT:qmailr@linux.stuco.uni-klu.ac.at [143.205.200.10]) by hub.org (8.9.2/8.9.1) with SMTP id OAA31350 for ; Wed, 17 Feb 1999 14:02:54 -0500 (EST) (envelope-from mmoedern@linux.stuco.uni-klu.ac.at) Received: (qmail 13113 invoked from network); 17 Feb 1999 19:02:48 -0000 Received: from kungfu.stuco.uni-klu.ac.at (HELO linux.stuco.uni-klu.ac.at) (143.205.200.98) by linux.stuco.uni-klu.ac.at with SMTP; 17 Feb 1999 19:02:48 -0000 Message-ID: <36CB1268.ED358843@linux.stuco.uni-klu.ac.at> Date: Wed, 17 Feb 1999 20:03:04 +0100 From: Martin =?iso-8859-1?Q?M=F6derndorfer?= Organization: IMAF Branch Austria X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: de-AT,en,ja MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Question about SQL FUnction Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit hi, i have some tables: create table person (nr int4, name varchar(50)); create table book(nr int4, title varchar(50), persnr int4); (persnr is the foreign key -> person.nr) now i have some CREATE FUNCTION get_new_nr(**TABLE**,**FIELDS**) RETURNS int4; AS 'SELECT MAX($2) FROM $1 +1;' LANGUAGE 'sql'; but **table** and **fields** needs some datatype. this function should return the max of a set of all numbers in person (+1) and return this. is it possible (and how ;-) to write such a very _flexible_ function?? MArtin