Building Interactive Forms Applications using Oracle

22
University of Sunderland COM 220 Lecture Six Slide 1 Building Interactive Building Interactive Forms Applications Forms Applications using Oracle using Oracle

description

Building Interactive Forms Applications using Oracle. Developer 6i. All databases have some kind of interface Oracle implementation is Developer 6i Allows non-programmers to access the DB by entering values on a form 4GL Tool - much of the work is done for you - PowerPoint PPT Presentation

Transcript of Building Interactive Forms Applications using Oracle

Page 1: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 1

Building Interactive Forms Building Interactive Forms ApplicationsApplicationsusing Oracleusing Oracle

Page 2: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 2

Developer 6iDeveloper 6i

• All databases have some kind of interface• Oracle implementation is Developer 6i

– Allows non-programmers to access the DB by entering values on a form

– 4GL Tool - much of the work is done for you– Usually a form would be developed for each

transaction within a system– 2 modes -a Designer Mode and an Operator

mode

Page 3: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 3

Developer 6iDeveloper 6i

Forms Designer

• Define transactions that combine data from multiple tables into a single form

• Quickly create default forms using a full set of defaults

• Customize all aspects of an application design

• Supports master/detail relationships

Page 4: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 4

Developer 6iDeveloper 6i

• A Forms application consist of objects• Objects contain information needed to

manipulate and produce an application• Oracle forms contains many different types

of object, e.g. Blocks, items, triggers, buttons, graphics

Page 5: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 5

Developer 6iDeveloper 6i

• A number of tools exist in order to manipulate these objects:

– Object Navigator

– Layout Editor

– Properties Window

– PL/SQL Editor

Page 6: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 6

Developer 6iDeveloper 6i

• Object Navigator– Provides a hierarchical view of all objects in a

form– used to create new objects– used to select existing objects

• Layout Editor– Provides a means of graphically displaying the

form– used to change a forms appearance - move

fields around etc

Page 7: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 7

Developer 6iDeveloper 6i

• Properties Editor– All objects on a form have properties– Used to change the characteristics of objects,

such as height and width, font, colour, capitals etc

• PL/SQL Editor– Used to write programs (called triggers) to add to

the functionality of a form

Page 8: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 8

PL/SQL & TriggersPL/SQL & Triggers

WHAT IS A TRIGGER ?

• Piece of custom code that is executed by an FORMS event

• Contains PL/SQL code.

• Every trigger has a name

• Name corresponds to an event

Page 9: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 9

TriggersTriggers

WHERE CAN A TRIGGER BE USED ?

Within a form at :

– FORM LEVEL– BLOCK LEVEL– ITEM LEVEL

Page 10: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 10

Object NavigatorObject Navigator

Page 11: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 11

Triggers UsesTriggers Uses

WHAT CAN A TRIGGER BE USED FOR?

• Perform data validation, data entry and data deletion.

• Control the logical flow of the application.

Page 12: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 12

Events ExamplesEvents Examples

• Pressing a button (WHEN-BUTTON-PRESSED)• Pressing tab key (KEY-NEXT-ITEM) • Leaving the item (POST-TEXT-ITEM)• Enter the block (PRE-BLOCK)• Ready record for Input (WHEN-NEW-RECORD-

INSTANCE)

Page 13: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 13

Example EventExample Event

• EXAMPLE :

KEY-NEXT-ITEM is a trigger used at item level. It is fired when the next item key (return or tab) is pressed. The normal function of the next item key is replaced by the code contained within the trigger

Page 14: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 14

PL/SQLPL/SQL

WHAT IS PL / SQL ?

– A programming language composed of procedural and non-procedural constructs.

– It is based around the ADA programming language

– Designed to augment SQL*PLUS

Page 15: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 15

PL/SQL BlockPL/SQL Block

• THE PL/SQL BLOCK

– A PL/SQL program is known as a block - short for “block of code”.

– The PL/SQL block is composed of 4 sections:• DECLARE

• BEGIN

• EXCEPTION

• END

Page 16: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 16

PL/SQL BlocksPL/SQL Blocks

PL/SQL BLOCK SECTIONS:

DECLARE

Declarative statements

BEGIN

Executable statements

EXCEPTION

Exception handlers

END;

Page 17: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 17

PL/SQL BlocksPL/SQL Blocks

DECLARE SECTION• Variables, constants and cursors to be used

in the block are used here.• Variables and constants must be defined

before they can be used.DECLAREsurname char(10);n1 number := 23.4567;joindate date;enddate date := ‘28-jan-95’;

Page 18: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 18

PL/SQL BlocksPL/SQL Blocks

• BEGIN SECTION– This tells oracle that executable statements follow.– Can be nested up to 200 levels.– Must be terminated by an end section

beginselect surnameinto :b1.surnamefrom tenantwhere :b1.property_id =

property_id;end;

Page 19: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 19

PL/SQL BlocksPL/SQL Blocks

EXCEPTION SECTION• Contains routines for handling exception

conditions.• There are two kinds of exception:-

Pre-defined

User-defined

THIS SECTION IS OPTIONAL

Page 20: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 20

PL/SQL ExamplePL/SQL Example

DECLARE

too_old exception;

BEGIN

if :b1.age > 35 then

raise too_old;

EXCEPTION

when too_old then

message (‘You are past it!’);

END;

Page 21: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 21

PL/SQL BlocksPL/SQL Blocks

END SECTION

All PL/SQL blocks must have an end

statement followed by a ;

Page 22: Building Interactive Forms Applications using Oracle

University of Sunderland COM 220 Lecture Six Slide 22

Further ReadingFurther Reading

• Developing Oracle Forms– COM220 Unit 2 - Introduction to Forms Part I– PL/SQL and Triggers– COM220 Unit 4 - Introduction to Forms Part II

• Next Week– Database Users and Administration