Académique Documents
Professionnel Documents
Culture Documents
SQL FORMS
STRUCTURE
3.1
BASIC CONCEPTS.
3.2
3.3
FORM CONSTRUCTION.
3.4
3.5
3.6
3.7
3.8
EXERCISE.
3.9
ANSWERS.
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.
AGE
22
19
18
27
TELNO.
6045853
8735456
2723442
6482755
Age
Telno
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
foRm Block
Field
Trigger
Procedure
Image
Help
Options
SQL*FORMS
Blk:
Fld:
Trg:
<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>
foRm Block
Field
Trigger Procedure
SQL*FORMS
Image
Help
Options
NEW FORM
NAME :
<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
(Select Columns)
Page Number : 1
Master Block :
[ ] Use Constraints
Base Line : 1
[ ] Delete Details
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>
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
Trg:
<Rep>
foRm Block
Field
Trigger Procedure
SQL*FORMS
Image
Help
Options
VIEW PAGE
PAGE :
<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
Press the select key sequence ( i.e. ^V ) to mark the first point.
Place the cursor at the first position ( i.e. the starting point )
After having marked the starting and ending position press the cut key sequence (i.e.
Esc+Del) to cut.
Move the cursor to the position at which you want to paste the cut portion.
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.
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
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>
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
---------------------------Trg:
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
<Rep>
3.8 EXERCISES
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.
7.
.frm
=================
********
==================
data type
Number(6)
varchar2(25)
number(3)
varchar2(15)