using variable in nextval - Mailing list pgsql-sql

From George Wadsworth
Subject using variable in nextval
Date
Msg-id 374DE6DC.E8D30DD@agritope.com
Whole thread Raw
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "Mark Wright"
Date:
Subject: How do I implement FIFO?
Next
From: "Andrei de Oliveira Mosman"
Date:
Subject: