oracle forms: create debug triggers

Post on 10-Feb-2017

686 Views

Category:

Software

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Creating & Debugging Triggers

Objectives

• How to Create Triggers?• Writing trigger code• Describe Built-in sub-programs used in Forms• When-Button-Pressed Trigger• When-Window-Closed Trigger• Debugging Triggers

How to Create a Trigger?

Trigger PL/SQL Block

• DECLARE

------- Declarative statements (OPTIONAL)• BEGIN

------- Executable statements (MANDATORY)

• EXCEPTION --------- Exception Handling. (OPTIONAL)

• END;

Variables in Form Builder

• PL/SQL variables must be declared in triggers or must be defined in a package

• Form Builder variables not required to be declared– Requires a Colon Prefix

Form Builder Variables

• ItemsFor presentation and user interaction :block_name.item_name

• Global variablesSession-wide character variable :GLOBAL.var_name

• System variablesForm status and control :SYSTEM.var_name

• ParametersPassing values in and out of module :PARAMENTER.parameter

Form Builder Built-in Subprograms

Built-ins belong to either:• The Standard Extensions package where no prefix is required• Another Form Builder package where a prefix is required

Built-in

Restricted Built-ins

Unrestricted Built-ins

Allowed onlyIn certain Triggers

Allowed In AnyTrigger orsubprogram

Built-in Subprograms

• EDIT_TEXTITEM• ENTER_QUERY• EXECUTE_QUERY• EXIT_FORM• GO_BLOCK• GO_ ITEM• NEXT_RECORD• PREVIOUS_RECORD

• MESSAGE• SHOW_ALERT• SHOW_ EDITOR • SHOW_ LOV• SHOW_VIEW• HIDE_VIEW• GET_ITEM_PROPERTY• SET_ITEM_PROPERTY

When-Button-Pressed Trigger

• Fires when the operator clicks a button.• Accepts restricted and unrestricted

built-ins.• Used for existing form, Display LOVs, Editors etc.

ExampleGO_BLOCK(‘EMP’);EXECUTE_QUERY;

When-Window-Closed Trigger

• Fires when the operator closes a window by clicking button.• Accepts restricted and unrestricted built-ins.• Used to programmatically close a window when the operator issues a

window manager-specific close command. You can close a window by using built-ins.

When-Window-ClosedTrigger at Form Level.

EXIT_FORM;

Debugging Triggers

• Monitor and Debug Triggers by:– Compiling and rectifying errors in the PL/SQL Editor– Displaying debug messages at run time– Invoking the PL/SQL Debugger

Debugging Triggers -Tips

• Connect to Database before compiling SQL statements.• Define triggers always at the correct level• Terminate statements with semicolon where ever necessary.• Watch for missing quotation marks• Place the triggers where the event will happen.

Running a Form In Debug Mode

FormsDebuggerWindow

Run Form Debug

Debug Triggers and Breakpoint

Everystatement

Debugger

Program Unit

Statement

Statement

Statement

Debugtrigger

Breakpointtrigger

Fire

Fire

Fire

Breakpoint

PL/SQL Debugger

Step Into

Step OverStep Out

Go Reset

Debug Commands

Summary

• Creating Trigger• From Built-ins• Restricted and Unrestricted built-ins• When-Button-Pressed trigger• When-Window-Closed Trigger

top related