Sie sind auf Seite 1von 15

CHAPTER-3.

SQL FORMS
STRUCTURE
3.1

BASIC CONCEPTS.

3.2

COMPONENTS OF AN ORACLE FORM.

3.3

FORM CONSTRUCTION.

3.4

FORM CREATION AND USE.

3.5

CREATING AN ORACLE DEFAULT FORM.


3.5.1

Getting Started On ORACLE Form Creation.

3.6

THE ORACLE USER DEFINED FORM.

3.7

USING THE GRAPHICS EDITOR TOOL.

3.8

EXERCISE.

3.9

ANSWERS.

3.1 BASIC CONCEPTS


Forms are the very heart of an RDBMS system. They are only means, by which a
programmer can ensure that there is valid data sitting in the table.
In real time application it is not always possible to enter valid data to the table by using
insert statement. ORACLE provides a programmer with a technique called form based method
of loading a table with validated data.
A form is designed via a tool, which allows various constraint definitions that can be
attached to form fields, so that data entered into the form field can be validated.

3.2 COMPONENTS OF AN ORACLE FORM


A form is made up of additional objects. These objects link the forms to table elements,
such as columns and provide control over the flow of form execution.
Blocks:

A form contains one or more blocks. A block may or may not be connected to the table.
Each block can be directly related to a single database table. Hence the field in the block is
associated with a column in the table. This direct relationship allows operators to query, update,
insert and delete data in the base table via the form.
A block can also indirectly relate to or carry information from any number of database
tables.
Blocks can be related to each other by specifying master-detail relationships. A masterdetail relationship corresponds to a primary-foreign key relationship between the base tables of
two blocks.
Fields:

Fields are containers for data with in a form. A field is always associated with a block.
Each block normally has one or more fields. The fields in a block usually corresponded to
columns of data in a table for the block that owns them.
Fields do not always correspond to the columns of a base table for the block. They can
hold calculated values, display related information from other tables or accept operator input for
later processing.
Pages:

Pages are collections of display information. Pages have characteristics such as size,
display type, etc. Pages differ from screens; screens are terminal display areas. Multiple pages
can appear on a screen or a page can be larger in size than the screen.

Triggers:

Triggers are blocks of code that can be attached to the form field. Triggers are eventbased. Triggers are fired upon an event happening on the form such as data entry into the field,
tabbing out of a form field etc.
Form-Level Procedures:

Form-based procedures are callable sets of commands. These procedures can use any
command that a trigger can use. Form level procedures are always attached to a form. They can
be called by another form-level procedure or a trigger on the form.
The various objects which a form holds can be summarized as follows :Forms

Pages

Blocks

Form-level

Triggers

Procedures
Fields

Triggers

Triggers
A form holds page(s), block(s), form-level procedure(s) and triggers(s). A block on the
form holds trigger(s) and field(s). A field on the form hold triggers(s).
3.3 FORM CONSTRUCTION
The simplest form is one where there is a single table connected to it i.e. one base table
attached to the form and only one row of the table displayed on the form. The form fields
created on the form take their data type and width from the columns in the table. This is known
as ORACLEs default form.

Table name : telbook


NAME
Paul
Kishore
Jyothi
Santosh

AGE
22
19
18
27

TELNO.
6045853
8735456
2723442
6482755

Diagram 3.1 : Data held in a table.


Form name : telbook
Name

Age

Telno

Diagram 3.2 : Data held in a form.


Only one record from the table telbook is displayed on the form in a diagram 3.2.
A block on the form is usually connected to a base table, which will have form fields on
it. The form fields are data pickup areas whose parameters are taken from the attached tables
selected columns.
3.4 FORM CREATION AND USE
In ORACLE, forms are created by using the forms creation tool via SQL*FORMS.
Using this tool, that has a screen painter, a data pickup screen can be designed to your liking.
Once the fields attributes are set, press the accept key sequence, Save the changes made
to the form, Generate and execute it.

At the time the form was created, we had attached a base table to the form. This is the
table whose data we shall be manipulating via the form. Also specified is whether the form
would display only a single record or a data set from the table.
3.5 CREATING AN ORACLE DEFAULT FORM
Before creating an ORACLE form you have to be recognized as a legitimate Unix user
and you need to get to the Unix system prompt. To do this, supply your login id and password.
3.5.1 GETTING STARTED ON ORACLE FORM CREATION
At the $ prompt type :

sqlforms30 c vt100:vt100

NOTE : This assumes your terminal type is vt100.


(Ask the System Administrator for information on your terminal type)
Next enter the user name and password.
NOTE : Each time an attempt to use any of the ORACLE tools is made, a login and password
will be demanded by the ORACLE DBA.
Once you have been accepted as a legitimate user of ORACLEs tools, the SQL*FORMS
main menu will appear. This will allow you to access the various tools for creating an ORACLE
form.
Action

foRm Block

Field

Trigger

Procedure

Image

Help

Options

SQL*FORMS

Perform Global Operations on forms


Frm:

Blk:

Fld:

Trg:

Screen 3.1 : SQL*FORMS opening screen.

<Rep>

In screen 3.1, the opening screen, the cursor is on the menu option Action. On pressing
<Enter>, from the dropdown menu that appears, select New.
Action

foRm Block

Field

Trigger Procedure
SQL*FORMS

Image

Help

Options

New
Open
------------------Copy
Rename
Delete
Load
------------------Print Doc >
Generate
Execute
------------------Save
Form Security
Quit
Create a new form
Frm:
Blk:

Fld:

Trg:

<Rep>

Screen 3.2 : The many choices in the Action option


Action

foRm Block

Field

Trigger Procedure
SQL*FORMS

Image

Help

Options

NEW FORM
NAME :

Enter the name of the form that you are creating


Frm:
Blk:
Fld:
Trg:
Screen 3.3 : Creating a new form.

<Rep>

Enter the name of the form to be created and press the accept key sequence (F4). Once
this is done, you are returned to the opening screen (screen 3.1), where you can create a default
block on the ORACLE form.
Using the right/left arrow keys, move the cursor to the Block option of the menu and from
the dropdown menu that appears, select Default.
NOTE : The key sequences may vary for different ORACLE installations. Ask your Systems
Administrator for help.
Action

foRm Block

Field

Trigger Procedure
SQL*FORMS

Image

Help

Options

Modify
Trigger
Default

Create a default
Frm:
Blk:
Fld:
Trg:
Screen 3.4 : Creating the default block.

<Rep>

Enter the Block Name and Base Table as shown in the screen 3.5.
Action

foRm Block

Field

Trigger Procedure
Default Block

Image

Help

Options

Block Name : ord


Base Table : ord
Sequence Number : 1
Records Displayed : 1

(Select Columns)
Page Number : 1

Master Block :

[ ] Use Constraints
Base Line : 1
[ ] Delete Details

-----------------------------------------Join Condition---------------------------------------Frm : ord

Blk:
Fld:
Trg:
Screen 3.5 : Default Block Screen.

<Rep>

Select the required columns to fit the block being created. Press the select key sequence
(^V) to see a list of the base table (base table used here is ord and its columns are as shown in the
screen 3.6) columns and screen 3.6 will appear.
Action

foRm Field

Trigger Procedure
Default Block

Block Name :
Base Table :

Select Columns

Sequence Number
Records Display

ORDID
ORDERDATE
COMMPLAN
CUSTID
SHIPDATE
TOTAL

Master Block :

Frm : ord

Image

Help Options

se Constraints
Line : 1

Delete Details

Blk :

Fld :

Trg :

<Rep>

Screen 3.6 : Selecting columns for the block.


If you want to deselect any column, go to that column using the arrow keys and press the
select key sequence (^V). After you have done this, press the accept key sequence to accept the
other columns. If all columns are required, press the accept key sequence at the very start.
Accept default values for the remaining options.
By pressing the accept key sequence now, you will be returned to the opening screen i.e.
screen 3.1. Select Save from the dropdown menu of Action, i.e. screen 3.2. The name of the
form last created will appear. To accept the same name for the form, hit enter.

This causes the form to be saved permanently as a reusable object. As this forms
aesthetics have been determined by ORACLE, it is known as a default ORACLE form.
When the form is generated SQL*FORMS creates a file with a frm extension. Execute
the default form.
3.6 THE ORACLE USER DEFINED FORM
Once your default ORACLE form is saved, you are returned back to the opening screen
i.e. screen 3.1. Choose Image from the menu. The screen that appears will look as screen 3.7.
Action

foRm Block

Field

Trigger Procedure
SQL*FORMS

Image

Help

Options

modify
Painter

Enter the screen painter on a particular page..


Frm:
Blk:
Fld:

Trg:

<Rep>

Screen 3.7 : The various choices in the image option.


Action

foRm Block

Field

Trigger Procedure
SQL*FORMS

Image

Help

Options

VIEW PAGE
PAGE :

Enter the number of the page that you want to view..


Frm:
Blk:
Fld:
Trg:
Screen 3.8 : Selecting the page to be created.

<Rep>

After this operation with the tool, the page you choose to work on and the selected base
tables fields will be displayed on the screen. This is the default ORACLE form. Using the
graphics editing tool, you can modify the form.
3.7

USING THE GRAPHICS EDITOR TOOL

To draw a box or a line :


To draw a box or a line, two points are required. For drawing a line, the two points will be the
starting and ending of the line. For drawing a box, these points will be the two diagonal corners
of the box.

Place the cursor at the first point.

Press the select key sequence ( i.e. ^V ) to mark the first point.

Move the cursor to the second point.

Press the select key sequence, to mark the second point.

Press the key sequence to draw ( i.e. F7 ).

Using the cut/paste capabilities of the form tool :


To perform the cut operation, again, two points are required i.e. a starting point and an ending
point.

Place the cursor at the first position ( i.e. the starting point )

Press the select key sequence.

Use the arrow keys to move the cursor.

Choose the second position (ending point).

Press the select key sequence.

After having marked the starting and ending position press the cut key sequence (i.e.
Esc+Del) to cut.

The marked portion will disappear.

Move the cursor to the position at which you want to paste the cut portion.

Press the paste key sequence ( i.e. Esc+F1).

The cut portion (held in the RAM buffer) is pasted at the chosen position.

Note : The marked portion is moved to a RAM buffer that can hold only a single block that is
cut, at any point in time. Therefore this should pasted, before cutting any another portion. If this
is not done, then the next cut portion in the buffer will overwrite the first cut portion.
Creating a field on a form that is not connected to a base table :
First and foremost, we have to select the point at which we want the field to appear.

Place the cursor at the first position.

Press the select key sequence.

Move the cursor to the second position.

Press the select key sequence.

Press the create field key sequence.

By doing this, you have defined the field length. Next, a Field Definition window appears as
shown in screen 3.9.
Action

foRm Block

Field

Trigger Procedure
Field Definition

Image

Help

Options

Field Name :
Date
Sequence Number :
5
Data Type : Number
(Select Attributes)
Field Length :
6
Query Length : 6
Display Length : 6
Screen Position : X : 20
Y : 4 Page : 1
(Editor Attributes)
Format Mask :
Default Value :
Hint : Enter value for : DATE
Valid Range : Low :
High :
Enforce Key :
List of values : Title :
Pos : X : Y:
--------------------------------- List of Values SQL Text ------------------------------------------------------------------------ Comment -------------------------------------------Enter the field name
Frm: ord
Blk: ord

Fld: DATE

Screen 3.9 : Defining the field attributes.

Trg:

<Rep>

The Data Type, in screen 3.9, will display the last used data type, defined during form
creation.
Various data types can be displayed, as shown in screen 3.10, where they can be tagged
to the current field.
Action

foRm Block

Field

Trigger Procedure
Field Definition

Field Name
DAT
Sequence Number : 5
Field Length :
6
Screen Position : X : 20
Format Mask :
Default Value :
Hint : Enter Value for : D
Valid Range : Low :
Enforce Key :
List of Values : Title :

CHAR
NUMBER
RNUMBER
DATE
JDATE
EDATE
TIME
ALPHA
INT
RINT
MONEY
RMONEY

--------------------------------Blk: ord

Help

Options

Data Type

----------------------------- L

Frm: Ord

Image

(Select Attributes)
Display Length : 6
(Editor Attributes)

h:
Pos : X : Y :
-------------------------------

-------------------------------Fld: DATE

Trg:

<Rep>

Screen 3.10 : Various data types displayed for a field.


Press the accept key sequence to accept information, displayed in screen 3.10. After the
form field has been declared you can attach various attributes to it vial the Select Attributes as
shown in screen 3.11.

Action

foRm Block

Field

Field Name
DATE
Sequence Number : 5
Field Length :
6
Screen Position : X : 20
Format Mask :
Default Value :
Hint : Enter Value for : D
Valid Range : Low :
h:
Enforce Key :
List of Values : Title :
----------------------------- L

Trigger Procedure
Field Definition

Image

Is the field based on a column in the base table?


Frm: Ord
Blk: ord
Fld: DATE

---------------------------Trg:

Screen 3.11 : Selecting field attributes.

REFERENCES:-

2. ORACLE 7

Options

[ X ] Table
(Select Attributes)
[ X ] Primary Key
Display Length : 6
[ X ] Displayed
(Editor Attributes)
[ X ] Required
[ X ] Input Allowed
[ ] Update Allowed
[ ] Update if Null
[ X ] Query Allowed
[ ] Uppercase
Pos : X : Y :
[ X ] Echo Input
[ ] Fixed Length
--------------------------[ ] Automatic Skip
[ ] Automatic Hint

-----------------------------------

1. ORACLE

Help

- Oracle press book.


- Ivan Bayross.

<Rep>

3.8 EXERCISES

A. FILL IN THE BLANKS :-

1. Form is made up of ______________ that links forms to table elements such as


columns.
2. In the form, _______ in the block is associated with a columns with the table.
3. A __________________ Corresponds to relationship between base tables of two
blocks.
4. __________ are block of code that can be attached to the form field.
5. In ORACLE, forms are created by using form creation tool via ___________.
6. To start with ORACLE forms, at the $ prompt you need to type _____________.
7. When the form is generated SQL*FORMS creates a file with _____ extension.
B. ANSWER THE FOLLOWING :-

8. What is a form? Explain how forms help the programmer.


9. Explain the different components of ORACLE Forms.
10. What is ORACLEs default form? Explain briefly with example.
11. Mention the different objects of SQL forms.
12. Mention the different Options that appear on SQL forms screen.
13. Briefly specify the different steps that are to be followed while creating a default
form for an already existing table.

B. PRACTICAL ASSIGNMENT :-

Create the following tables using suitable SQL statements. For each of the tables
created, create the default forms. The table names along with description are given
below.
EMPLOYEE
Name
emp-no
emp-name
dept-name
Salary

data type
varchar2(6)
varchar2(25)
varchar2(15)
number(6,2)

ACCOUNTS
Name
data type
Account-no
Number(6)
Cust-name
varchar2(25)
Account-type varchar2(5)
balance-amt
number(7,2)

STUDENT
Name
Reg-no
Stud-name
total-marks
Result

3.9 ANSWERS
A. 1.

additional objects

2.

fields

3.

Master-detail relationship

4.

Triggers

5.

SQL *Forms

6.

Sqlforms30 c vt100 : vt100

7.

.frm
=================

********

==================

data type
Number(6)
varchar2(25)
number(3)
varchar2(15)

Das könnte Ihnen auch gefallen