pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pragati Kenkare <pkenkare@writeme.com>
To: pgsql-novice@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: 'select nextval('seq_name');' in a function ?
Date: Sat, 24 Jan 2004 04:04:10 -0500
Message-ID: <20040124090410.63451.qmail@iname.com> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <20040124090410.63451.qmail@iname.com>
Permalink:  ../20040124090410.63451.qmail@iname.com/
Also on:    postgresql.org/message-id/20040124090410.63451.qmail@iname.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pkenkare@writeme.com, pgsql-novice@postgresql.org
  Subject: Re: 'select nextval('seq_name');' in a function ?
  In-Reply-To: <20040124090410.63451.qmail@iname.com>

* 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