Обсуждение: using variable in nextval

Поиск
Список
Период
Сортировка

using variable in nextval

От
George Wadsworth
Дата:
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