我需要一个包含所有现有序列及其值的列表。我试过了:
SELECT RDB$GENERATOR_NAME, GEN_ID(RDB$GENERATOR_NAME, 0) FROM RDB$GENERATORS;
或
SELECT G.RDB$GENERATOR_NAME, GEN_ID(G.RDB$GENERATOR_NAME, 0) FROM RDB$GENERATORS G;
但这些不正确,因为GEN_ID()
将第一个参数视为非常生成器名称,即尝试访问生成器G.RDB$GENERATOR_NAME
而不是G.RDB$GENERATOR_NAME
的值
答案 0 :(得分:5)
execute block
returns (
out_name char(31),
out_value bigint)
as
begin
for select rdb$generator_name from rdb$generators where rdb$system_flag is distinct from 1 into out_name do
begin
execute statement 'select gen_id(' || out_name || ', 0) from rdb$database' into out_value;
suspend;
end
end