Oracle Forms 6i

23
ORACLE FORMS 6I Enterprise application developers need a declarative model-based approach. Oracle Designer and Oracle Forms Developer provide this solution, using Oracle Forms Services as the primary deployment option. What Is Oracle Forms Developer? A productive development environment for Internet business applications Data entry Query screens It provides a set of tools that enable business developers to easily and quickly construct sophisticated database forms and business logic with a minimum of effort. Oracle Forms Services? Oracle Forms Services is a component of Oracle9i Application Server for delivering Oracle Forms Developer applications to the Internet. Oracle Forms Services uses a three-tier architecture to deploy database applications: 1. The client tier contains the Web browser, where the application is displayed and used. 2. The middle tier is the application server, where the application logic and server software reside. 3. The database tier is the database server, where enterprise data is stored.

description

Oracle Forms 6i

Transcript of Oracle Forms 6i

Page 1: Oracle Forms 6i

ORACLE FORMS 6I

Enterprise application developers need a declarative model-based approach. Oracle Designer and Oracle Forms Developer provide this solution, using Oracle Forms Services as the primary deployment option.

What Is Oracle Forms Developer?

A productive development environment for Internet business applications Data entry Query screens

It provides a set of tools that enable business developers to easily and quickly construct

sophisticated database forms and business logic with a minimum of effort.

Oracle Forms Services?

Oracle Forms Services is a component of Oracle9i Application Server for delivering

Oracle Forms Developer applications to the Internet. Oracle Forms Services uses a three-tier architecture to deploy database

applications:1. The client tier contains the Web browser, where the application is displayed and used. 2. The middle tier is the application server, where the application logic

and server software reside.3. The database tier is the database server, where enterprise data is

stored.

Page 2: Oracle Forms 6i

Form Builder Components

1. Object NavigatorThe Object Navigator is a hierarchical browsing and editing interface that enables youto locate and manipulate application objects quickly and easily.

Features include:• A hierarchy represented by indentation and expandable nodes.• Find field and icons, enabling forward and backward searches for any level of node or for an individual item in a node.• Icons in the vertical toolbar replicating common File menu functions.• An icon next to each object to indicate the object type.

2. Property PaletteAll objects in a module, including the module itself, have properties that you can seeand modify in the Property Palette.

Features include:• Copy and reuse properties from another object• Find field and icons, similar to Object Navigator

3. Layout Editor (or Layout Model)The Layout Editor is a graphical design facility for creating and arranging interfaceitems and graphical objects in your application. When you use the Tool Palette and theToolbar available in the Layout Editor, you can design the style, color, size, andarrangement of visual objects in the application.

4. PL/SQL EditorThe PL/SQL Editor is the integrated functionality of Oracle Procedure Builder thatexists within the Form Builder.

It provides:• Development of triggers, procedures, functions, and packages in Oracle Forms Developer as well as the database• Development of libraries to hold PL/SQL program units• Statement-level debugging of PL/SQL at run time

Page 3: Oracle Forms 6i

Types of BlocksIn Form Builder there are two main types of blocks: 1. data blocks and 2. control blocks.

1. DATA BLOCKS

A data block is associated with a specific database table (or view), a stored procedure, a FROM clause query, or transactional triggers.

If it is based on a table (or view), the data block can be based on only one base table

2. Control Blocks

A control block is not associated with a database, and its items do not relate to any columns within any database table.

Its items are called control items.

What Is a Window?A window is a container for all visual objects that make up a Form Builder application.It is similar to an empty picture frame.

What Is a Canvas?A canvas is a surface inside a window container on which you place visual objectssuch as interface items and graphics.

What Is a Content Canvas?

A content canvas is the base canvasthat occupies the entire content pane of the window in which it displays. The contentcanvas is the default canvas type.

Form Builder provides three other types of canvaseswhich are:• Stacked canvas• Toolbar canvas• Tab canvasWhen you create a canvas, you specify its type by setting the Canvas Type property.The type determines how the canvas is displayed in the window to which it isassigned.

Page 4: Oracle Forms 6i

What Is a Stacked Canvas?A stacked canvas is displayed on top of, or stacked on, the content canvas assigned toa window.

What Is a Toolbar Canvas?A toolbar canvas is a special type of canvas that you can create to hold buttons andother frequently used GUI elements.

The Three Toolbar Types• Vertical toolbar: Use a vertical toolbar to position all your tool itemsdown the left or right hand side of your window.• Horizontal toolbar: Use a horizontal toolbar to position all your toolitems and controls across the top or bottom of your window.• MDI toolbar: Use an MDI toolbar to avoid creating more than onetoolbar for a Form Builder application that uses multiple windows.

What Is a Tab Canvas?A tab canvas is a special type of canvas that enables you to organize and displayrelated information on separate tabs.

Page 5: Oracle Forms 6i

What Is a Trigger?A trigger is a program unit that is executed (fired) due to an event.You can use triggers to add or modify form functionality in a procedural wayEvery trigger that you define is associated with a specific event.

events include the following:• Query-related events• Data entry and validation• Logical navigation or physical mouse movement• Operator interaction with items in the form• Internal events in the form• Errors and messages

Trigger CharacteristicsYou write Form Builder triggers in PL/SQL. These triggers are mostly fired by events within a form module

Trigger ComponentsThere are three main components to consider when you design a trigger in FormBuilder:Component Description1. Trigger type - Defines the specific event that will cause the trigger to fire2. Trigger code - The body of PL/SQL that defines the actions of the trigger3. Trigger scope - The level in a form module at which the trigger is defined— determining the scope of events that will be detected by the trigger

Trigger ScopeThe scope of a trigger is determined by its position in the form object hierarchy, thatis, the type of object under which you create the trigger.

There are three possible levels:

1. Form level - The trigger belongs to the form and can fire due to events across the entire form2. Block level - The trigger belongs to a block and can only fire when this block is the current block3. Item level - The trigger belongs to an individual item and can only fire when this item is the current item

Page 6: Oracle Forms 6i

Trigger Type

The trigger type determines which type of event fires it. There are more than 100 builtintriggers, each identified by a specific name.

Trigger Prefix Description1. Key- Fires in place of the standard action of a function key2. On- Fires in place of standard processing (used to replace or bypass a process)3. Pre- Fires on an event that occurs just before an action (for example, before

a query is executed)4.Post- Fires just after an action (for example, after a query is executed)

5.When- Fires in addition to standard processing (used to augment functionality)

Trigger CodeThe code of the trigger defines the actions for the trigger to perform when it fires.Write this code as an anonymous PL/SQL block by using the PL/SQL Editor.

Using Smart TriggersSmart Triggers item expands to a list of common triggers that are appropriate for theselected object.

Using Variables in Form BuilderIn triggers and subprograms, Form Builder generally accepts two types of variables forstoring values:

1. PL/SQL variables: These must be declared in a DECLARE section, andremain available until the end of the declaring block. They are notprefixed by a colon. If declared in a PL/SQL package, a variable isaccessible across all triggers that access this package.2. Form Builder variables: Variable types maintained by the Form Builder.These are seen by PL/SQL as external variables, and require a colon (:)prefix to distinguish them from PL/SQL objects (except when theirname is passed as a character string to a subprogram). Form Buildervariables are not formally declared in a DECLARE section, and canexist outside the scope of a PL/SQL block.

Page 7: Oracle Forms 6i

Form Builder VariablesThe following variables are available for the storage and manipulation of values:Form Builder Variable Type Description

1. Item (text, list, check box, and so on) Scope: Current form and attached menuUse: Presentation and interaction with user

2. Global variable Scope: All modules in current sessionUse: Session-wide storage of character data

3. System variable Scope: Current form and attached menuUse: Form status and control

4. Parameter Scope: Current moduleUse: Passing values in and out of module

Page 8: Oracle Forms 6i

DESIGN FORM AS FOLLOWS

EXECUTE CODE: GO_BLOCK('EMP'); EXECUTE_QUERY;

LAST : FIRST: GO_BLOCK('EMP'); GO_BLOCK('EMP'); LAST_RECORD; FIRST_RECORD;

NEXT: GO_BLOCK('EMP'); NEXT_RECORD;

PREVIOUS GO_BLOCK('EMP'); PREVIOUS_RECORD;

EXIT: EXIT_FORM;

Page 9: Oracle Forms 6i

T_EMPNO “POST_TEXT_ITEM”

SELECT ENAME,JOB,SAL,DEPTNO INTO :T_ENAME,:T_JOB,:T_SAL,:T_DEPTNO FROM EMP WHERE EMPNO=:T_EMPNO;

Page 10: Oracle Forms 6i

DESIGN FORM AS FOLLOWS

ADD CODE

DECLAREN NUMBER;

BEGIN SELECT MAX(EMPNO) INTO N FROM EMP; IF N IS NULL THEN :T_EMPNO:=1001; ELSE :T_EMPNO:=N+1; END IF; END;

SAVE CODE

INSERT INTO EMP(EMPNO,ENAME,JOB,SAL,DEPTNO) VALUES(:T_EMPNO,:T_ENAME,:T_JOB,:T_SAL,:T_DEPTNO);COMMIT;CLEAR_FORM;

Page 11: Oracle Forms 6i

MODIFY

UPDATE EMP SET ENAME=:T_ENAME,JOB=:T_JOB,SAL=:T_SAL,DEPTNO=:T_DEPTNO WHERE EMPNO=:T_EMPNO;COMMIT;CLEAR_FORM;

DELETE

DELETE FROM EMP WHERE EMPNO=:T_EMPNO;COMMIT;CLEAR_FORM;

FIND

IF :T_EMPNO IS NULL THEN:T_EMPNO:=7654;

ELSESELECT ENAME,JOB,SAL,DEPTNO

INTO :T_ENAME,:T_JOB,:T_SAL,:T_DEPTNO FROM EMP WHERE EMPNO=:T_EMPNO;END IF;

CLEAR

CLEAR_FORM;

EXIT

EXIT_FORM;

T_JOB “POST_TEXT_ITEM”

if :T_JOB='CLERK' THEN:T_SAL:=1200;

ELSif :T_JOB='MANAGER' THEN:T_SAL:=2200;

ELSE:T_SAL:=3200;

END IF;

Page 12: Oracle Forms 6i

LOV

- FOR FINDING RECORDS CREATE AN LOV

- CALLING LOV WHEN YOU CLICK ON FIND BUTTON

DECLAREN BOOLEAN;

BEGIN N:=SHOW_LOV('LOV11');

END;

Page 13: Oracle Forms 6i

ALERTS

CREATE AN ALERT TO CALL WHEN EVER YOU TRY TO EXIT FROM FORM

- IN EXIT BUTTON WRITE FOLLOWING CODE

DECLAREN NUMBER;

BEGINN:=SHOW_ALERT('ALERT28');IF N=ALERT_BUTTON1 THEN

EXIT_FORM;ELSE

GO_BLOCK('BLOCK3');END IF;

END;

Page 14: Oracle Forms 6i

WORKING WITH PROGRAM UNITS

CREATE A PROCEDURE TO CALL WHEN YOU CLICK ON EXIT BUTTON

NOW WRITE FOLLOWING CODE

PROCEDURE CLOSEFORM ISN NUMBER;

BEGINN:=SHOW_ALERT('ALERT28');IF N=ALERT_BUTTON1 THEN

EXIT_FORM;ELSE

GO_BLOCK('BLOCK3');END IF;

END;

- NOW CALL THE PROCEDURE IN “EXIT BUTTON”CLOSEFORM;

Page 15: Oracle Forms 6i

WORKING WITH MENUS

DESIGN FOLLOWING FORM

NOW CREATE MENU

OPEN MENU AND DESIGN MENU AS FOLLOWS

- WRITE THE CODE FOR THE MENU ITEMS

EXECUTE CODE: GO_BLOCK('EMP'); EXECUTE_QUERY;

Page 16: Oracle Forms 6i

LAST : FIRST: GO_BLOCK('EMP'); GO_BLOCK('EMP'); LAST_RECORD; FIRST_RECORD;

NEXT: GO_BLOCK('EMP'); NEXT_RECORD;

PREVIOUS GO_BLOCK('EMP'); PREVIOUS_RECORD;

EXIT: EXIT_FORM;

- NOW CLOSE MENU AND- SAVE THE MENU IN C:\MYMENU- NOW COMPILE MENU [CTRL+T]- NOW SET EMP MODULE PROPERTY AS

- NOW RUN THE FORM - YOU CAN SEE YOUR MYMENU WILL DISPLAY