Function For Newly INSERTED VALUE

From: "shreedhar" <shreedhar(at)lucidindia(dot)net>
To: "Postgres" <pgsql-admin(at)postgresql(dot)org>
Subject: Function For Newly INSERTED VALUE
Date: 2002-09-12 07:17:27
Message-ID: 002601c25a2c$7372f610$1201a8c0@a4005
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi All,

The following function is possible where input is 'Sequence Name' and output
is 'Inserted value' language 'plpgsql'

DECLARE
sequence ALIAS FOR $1;
inserted_rec integer;
sql text;
BEGIN
sql := 'SELECT INTO inserted_rec * from ' || sequence;
EXECUTE sql;
IF inserted_rec.last_value IS NULL THEN
RETURN 0;
ELSE
RETURN inserted_rec.last_value;
END IF;
END;

The same is working for the following

DECLARE
sequence ALIAS FOR $1;
inserted_rec integer;
sql text;
BEGIN
SELECT INTO inserted_rec * from sequencename;
IF inserted_rec.last_value IS NULL THEN
RETURN 0;
ELSE
RETURN inserted_rec.last_value;
END IF;
END;

How can I make use the top one.

With Best Regards,
Sreedhar Bhaskararaju 1,2nd Main Road, KottuGardens, Chennai - 600 085 Ph :
4475111 Email : shreedhar(at)lucidindia(dot)net

Browse pgsql-admin by date

  From Date Subject
Next Message Krammer Clemens 2002-09-12 07:23:06 disk spin down
Previous Message Lamar Owen 2002-09-12 03:56:04 Re: 7.2.2 RPM build failure