Hi all,
I am trying to write plpgsql that must create a sequence generators during runtime. The min/max values are provided as
functionparameters.
The following isn't working for me and I'm not too surprised, but not sure of the best way to proceed. I am guessing I
needto use PERFORM, EXECUTE or cursors or something?
==
create or replace function my_number_assigner(
p_floor int,
p_ceiling int
) returns void as
$$
create sequence num_generator minvalue p_floor maxvalue p_ceiling start with p_floor;
end
$$
language plpgsql;
==
ERROR: syntax error at or near "$1"
LINE 1: create sequence num_generator minvalue $1 maxvalue $2 s...
^
QUERY: create sequence num_generator minvalue $1 maxvalue $2 start with $1
CONTEXT: SQL statement in PL/PgSQL function "my_number_assigner" near line 35
I presume that the create sequence expression wants to see literals instead of variables, right? I knew I was going to
runinto this situation sooner or later. What should I be doing here?
- Leon