在 Firebird 中,DECLARE
语句可以列在EXECUTE BLOCK
语句的开头:
EXECUTE BLOCK [(<inparams>)]
[RETURNS (<outparams>)]
AS
[<declarations>]
BEGIN
[<PSQL statements>]
END
在一个块中,不可能有更多DECLARE
的语句,即所有变量都是全局范围的,对于整个块。是否有任何解决方法可以在 Firebird 中仅为嵌套块的范围声明局部变量?嵌套EXECUTE BLOCK
调用是不可能的:
EXECUTE BLOCK AS
DECLARE i INTEGER;
BEGIN
EXECUTE BLOCK AS -- This doesn't compile
DECLARE j INTEGER;
BEGIN
END
END