pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: shreedhar <shreedhar@lucidindia.net>
To: Postgres <pgsql-admin@postgresql.org>
Subject: Function For Newly INSERTED VALUE
Date: Thu, 12 Sep 2002 12:47:27 +0530
Message-ID: <002601c25a2c$7372f610$1201a8c0@a4005> (raw)

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@lucidindia.net




Message-ID: <002601c25a2c$7372f610$1201a8c0@a4005>
Permalink:  ../002601c25a2c$7372f610$1201a8c0@a4005/
Also on:    postgresql.org/message-id/002601c25a2c$7372f610$1201a8c0@a4005

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: shreedhar@lucidindia.net
  Subject: Re: Function For Newly INSERTED VALUE
  In-Reply-To: <002601c25a2c$7372f610$1201a8c0@a4005>
  References: <002601c25a2c$7372f610$1201a8c0@a4005>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox