In Firebird, DECLARE
statements can be listed at the beginning of an EXECUTE BLOCK
statement:
EXECUTE BLOCK [(<inparams>)]
[RETURNS (<outparams>)]
AS
[<declarations>]
BEGIN
[<PSQL statements>]
END
Within a block, no further DECLARE
statements are possible, i.e. all variables are globally scoped, for the entire block. Is there any workaround to declare local variables for the scope of a nested block only, in Firebird? Nesting EXECUTE BLOCK
calls isn't possible:
EXECUTE BLOCK AS
DECLARE i INTEGER;
BEGIN
EXECUTE BLOCK AS -- This doesn't compile
DECLARE j INTEGER;
BEGIN
END
END