Question about SQL FUnction

From: Martin Möderndorfer <mmoedern(at)linux(dot)stuco(dot)uni-klu(dot)ac(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: Question about SQL FUnction
Date: 1999-02-17 19:03:04
Message-ID: 36CB1268.ED358843@linux.stuco.uni-klu.ac.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Atika 1999-02-17 20:49:57
Previous Message Terry Mackintosh 1999-02-17 02:29:17 Re: [ADMIN] Creating Textfiles out of tables