2. Objectives
• Explain Flexible Coding
• Advantages of using system variables
• Identify built-in subprograms that assist flexible coding
• Write code to reference objects by internal ID
http://ebiztechnics.blogspot.com
3. Flexible Coding
• What do you mean by Flexible Coding?
• Is generic code
• Is reusable
• Avoid hard coded object names
• Make maintenance easier
• Increases Productivity
http://ebiztechnics.blogspot.com
5. System Variables
• Trigger focus:
– SYSTEM.TRIGGER_BLOCK
– SYSTEM.TRIGGER_RECORD
– SYSTEM.TRIGGER_ITEM
Note: prefix colon (:) before these variables
Example: :SYSTEM.CURSOR_ITEM
http://ebiztechnics.blogspot.com
6. Examples
• IF :SYSTEM.CURSOR_BLOCK=‘DEPT’ THEN
GO_BLOCK(‘EMP’);
ELSIF :SYSTEM.CURSOR_BLOCK=‘EMP’ THEN
GO_BLOCK(‘SALGRADE’);
ELSIF :SYSTEM.CURSOR_BLOCK=‘SALGRADE’ THEN
GO_BLOCK(‘DEPT’);
END IF;
http://ebiztechnics.blogspot.com
9. Object ID
Finding and Object ID:
Alt_id :=
FIND_ALERT(’Del_alert’)
Referencing an Object by ID:
...SHOW_ALERT(Alt_id)
Referencing and Object by Name:
...SHOW_ALERT(‘Del_alert’)
http://ebiztechnics.blogspot.com
11. Using Object IDs
• Declare a PL/SQL variable of the same data type.
• Use the variable for any later reference to the object.
• Use the variable within the current PL/SQL block only.
http://ebiztechnics.blogspot.com
13. Using Object IDs
• A PL/SQL variable has limited scope.
• An .id extension:
– Broadens the scope
– Converts to a numeric format
– Enables assignment to a global variable
– Converts back to the object data type
http://ebiztechnics.blogspot.com
14. Summary
• User System Variables
– To avoid hard coded object names
– Make maintenance easier
• Use GET_”object”_PROPERTY Built-ins to get and
SET_”object”_PROPERTY Built-ins to Set the object properties at
run time.
• Use FIND_”object” functions to find the internal Object Ids.
http://ebiztechnics.blogspot.com
Editor's Notes
Note:
The best way to learn about system variables is to look at their values when a
Form is running. You can examine the system variables by using the Debugger.
Note:
Use the FIND_ built-in subprograms only when referring to an object more than once in the
Same trigger or PL/SQL program unit.