Question about SQL FUnction - Mailing list pgsql-sql

From Martin Möderndorfer
Subject Question about SQL FUnction
Date
Msg-id 36CB1268.ED358843@linux.stuco.uni-klu.ac.at
Whole thread Raw
Responses Re: [SQL] Question about SQL FUnction  (David Martinez Cuevas <david@estadistica.unam.mx>)
List 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

pgsql-sql by date:

Previous
From: Terry Mackintosh
Date:
Subject: Re: [ADMIN] Creating Textfiles out of tables
Next
From: Atika
Date:
Subject: ...