pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: George Wadsworth <georgew@agritope.com>
To: pgsql-sql@postgresql.org
To: pgsql-general@postgresql.org
Subject: using variable in nextval
Date: Thu, 27 May 1999 17:44:12 -0700
Message-ID: <374DE6DC.E8D30DD@agritope.com> (raw)

Hi!
I'm trying to use a variable as the sequence name in a nextval:
using pgsql 6.4.2, PL/pgSQL called from a trigger

-- site is a char() used to describe the location
-- generation is an int used for generations of plants
-- each site/generation combo has it's own sequence
site := new.site;
gen := new.generation;
sequencename := site || gen;
newSerial := nextval(sequencename);

I get ERROR: Only constant sequence names are acceptable for function
'nextval'

I've tried all sorts of quote, double quotes, etc and this is the
closest I've got.
Does anyone know of a workaround? There are 12 different combinations
and I don't really want to make a big, nasty, nested if...
thanks in advance.

-George Wadsworth




Message-ID: <374DE6DC.E8D30DD@agritope.com>
Permalink:  ../374DE6DC.E8D30DD@agritope.com/
Also on:    postgresql.org/message-id/374DE6DC.E8D30DD@agritope.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 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-sql@postgresql.org
  Cc: georgew@agritope.com, pgsql-general@postgresql.org
  Subject: Re: using variable in nextval
  In-Reply-To: <374DE6DC.E8D30DD@agritope.com>
  References: <374DE6DC.E8D30DD@agritope.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