Thursday, August 21, 2008

Oracle Forms-DEFAULT_VALUE Built-in

DEFAULT_VALUE built-in in oracle forms is used for assign value to variable if value of variable is NULL.
IF :DBT_BRANCH.LOCATION IS NULL THEN
:DBT_BRANCH.LOCATION:='Pune';
END IF;
is equivalent to
default_value('Pune','DBT_BRANCH.LOCATION');
But DEFAULT_VALUE is noramally used to initialize global variable if they are not exist. If global variable are not exist in system then it will create new one or else assign value if its value is NULL.

:SYSTEM.TRIGGER_ITEM vs :SYSTEM.CURRENT_ITEM

Both :SYSTEM.TRIGGER_ITEM and :SYSTEM.CURRENT_ITEM has character string values which is in form of BLOCK_NAME.ITEMN_NAME. :SYSTEM.TRIGGER_ITEM represents the Item in the scope of firing trigger. When :SYSTEM.TRIGGER_ITEM is referenced in KEY-XXX triggers then only it returns the values same as :SYSTEM.CURSOR_ITEM. :SYSTEM.CURSOR_ITEM represents currently focused item and may change in a trigger if navigation takes place. Value of :SYSTEM.TRIGGER_ITEM remains same from begining of trigger till end.

Monday, August 18, 2008

Performance Guideline-Use a PL/SQL variable instead of a bind variable

Use a PL/SQL variable instead of a bind variable. Referencing a bind variable that represents a forms item (such as :DEPT.DEPTNO) requires forms to find the item in its internal list. Therefore, each time your code uses that same bind variable, the lookup has to occur again. If you have code that uses the same bind variable more than once in the PL/SQL block, create a variable instead. For example, the following code stores the value of :DEPT.DEPTNO in a variable and references that variable instead of repeating a lookup to find the value.
For Example,
DECLARE
v_deptno NUMBER := ept.deptno;
BEGIN
message('The department # is ' v_deptno);
IF v_deptno < 0
THEN
message('Incorrect department number');
...;
END IF;
--
:control.department_num := v_deptno;
END;

Tuesday, August 12, 2008

Global Variables

Introduction to Global Variables:
Global variables in Oracle forms are the variable which are accessible thruout system (or entire runform session) until we erase it. You can declare these global variables anywhere in PL/SQL code (Triggers or Program Units). Main advantage of using global variables is that using global variable is very easy and simple. On the fly you can declare any number of variables. Value of global variable is preserved for whole runform session. In Oracle 10g forms you can store up to 4000 BYTES of CHAR data, while in previous version it was limited to 255 BYTES CHAR only.
Declaration of Global variables Variables:
In Oracle form style of declaring global variable is quite different than normal PL/SQL variables. PL/SQL variable are always declared in Declaration section of PL/SQL code, while you cannot declare global variables in declaration section. Global variables are initialized by assigning value to them.
e.g.
1) Declaring PL/SQL local Variable
declare
cMyName VARCHAR2(30);
begin
cMyName :='James Bond';
........;
..........;
END;

2) Declaring Global variables:
BEGIN
:Global.myName:='James Bond'; -- Globals are prefixed by ':Global.'
.....;
.....;
END;

Remember that DATATYPE for global variable is always CHAR. So if you are assigning DATE, NUMBER data to global variable and reassigning these global values to any other variable having Datatype other than CHAR, there is always overhead of implicit data-type conversion. If you are using global variables heavily in your system then always take care that you erase global variables after use. Since One global variable requires 4000 BYTES size in Oracle 10g Forms and 255 in previous version, your application will consuming too much amount of memory for global variables variables. It reduces performance drastically.
Removing/Erasing Global variables:
You can remove global variable and release its memory by using 'ERASE' Build-in.
ERASE('Global.myName');
Referencing a global variable that has not been initialized through assignment causes a runtime error.