X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E7C47D1CC96 for ; Sat, 24 Jan 2004 09:04:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 13420-04 for ; Sat, 24 Jan 2004 05:04:15 -0400 (AST) Received: from spf13.us4.outblaze.com (spf13.us4.outblaze.com [205.158.62.67]) by svr1.postgresql.org (Postfix) with ESMTP id 4C476D1E7FA for ; Sat, 24 Jan 2004 05:04:13 -0400 (AST) Received: from spf0.us4.outblaze.com (spf0.us4.outblaze.com [205.158.62.68]) by spf13.us4.outblaze.com (Postfix) with QMQP id BCBC11800FE5 for ; Sat, 24 Jan 2004 09:04:10 +0000 (GMT) Received: (qmail 48391 invoked from network); 24 Jan 2004 09:04:10 -0000 Received: from unknown (HELO ws1-6.us4.outblaze.com) (205.158.62.53) by mailin.us4.outblaze.com with SMTP; 24 Jan 2004 09:04:10 -0000 Received: (qmail 63452 invoked by uid 1001); 24 Jan 2004 09:04:10 -0000 Message-ID: <20040124090410.63451.qmail@iname.com> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Mailer: MIME-tools 5.41 (Entity 5.404) Received: from [63.202.178.200] by ws1-6.us4.outblaze.com with http for pkenkare@writeme.com; Sat, 24 Jan 2004 04:04:10 -0500 From: "Pragati Kenkare" To: pgsql-novice@postgresql.org Cc: pgsql-sql@postgresql.org Date: Sat, 24 Jan 2004 04:04:10 -0500 Subject: 'select nextval('seq_name');' in a function ? X-Originating-Ip: 63.202.178.200 X-Originating-Server: ws1-6.us4.outblaze.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/303 X-Sequence-Number: 9458 Hi, I am new to postgresql. Using PostgreSQL 7.3.2, I did the following. testdb#CREATE SEQUENCE principal_id increment 1 start 1000 cache 5; testdb#CREATE TABLE principal (principal_id int not null, name text, constraint pk_principal primary key(principal_id)); testdb#CREATE FUNCTION getnext_principal_id(int) returns int as 'select nextval('principal_id');' language 'SQL'; This gives -> ERROR: parser: parse error at or near "principal_id" at character ... Please help. Basically, I want to write equivalent of the following Oracle procedure: create or replace procedure getnext_principal_id (retVal out principal.principal_id%TYPE ) as begin select principal_id.nextval into retValue from dual; end; Thanks much, Pragati -- _______________________________________________ Get your free email from http://www.iname.com