Oracle Form里,有两种全局变量,一种是Parameter variables,另外一种是Global variables
Parameter variables是Form内的全局变量,Form内的所有Trigger,Program Unit都可以读取或者修改这个:parameter.var,但注意:parameter.var不能跨Form调用。
Global variables是系统级别的全局变量,可在不同的Form间读取和修改。
Global variables的声明方式不同于普通的变量,普通的变量我们会定义在declare区,但是Global变量不需要显示声明,只要给:global.var赋值,就已经完成了声明。
1) Declaring PL/SQL local Variable
declare
var VARCHAR2(30);
begin
var :=\'James Bond\';
........;
END;
2) Declaring Global variables:
BEGIN
:Global.var:=\'James Bond\'; -- Globals are prefixed by \':Global.\'
.....;
END;
关于:global.var还有几点需要记住:
1.:global.var的数据类型总是CHAR类型,如果要存储其他类型的值,需要类型转换。
2.Oracle Forms 10g可以缓存4000 Bytes的全局变量,Form 6i可以缓存255 Bytes内存大小的全局变量。(太大的全局变量缓存区可能会影响性能)
3.清除全局变量的代码,ERASE(\'Global.var1\');
Forms6i online-help:
==================================================
Parameter values are not visible across multiple forms. Thus, even if there is a parameter named p1 defined in both Form A and Form B, each form has a separate context, and setting the value of p1 in Form B has no effect on the value of p1 in Form A. For this reason, parameters are useful in multiple-form applications primarily as inputs to a form when it is first invoked.
If your application requires variables whose values are visible across called forms, you should use global variables. Global variables are visible across called forms, and remain active until they are explicitly deleted with the ERASE built-in procedure, or until the session ends.
<!-- Baidu Button BEGIN -->