Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B87C2476018 for ; Thu, 12 Sep 2002 03:13:43 -0400 (EDT) Received: from lucidindia.net (unknown [61.11.73.194]) by postgresql.org (Postfix) with ESMTP id 4A786475F62 for ; Thu, 12 Sep 2002 03:13:39 -0400 (EDT) Received: from a4005 ([192.168.1.18]) by lucidindia.net (8.11.6/8.11.6) with SMTP id g8C7HSt02780 for ; Thu, 12 Sep 2002 12:47:28 +0530 Message-ID: <002601c25a2c$7372f610$1201a8c0@a4005> From: "shreedhar" To: "Postgres" Subject: Function For Newly INSERTED VALUE Date: Thu, 12 Sep 2002 12:47:27 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/134 X-Sequence-Number: 5673 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