Adding New Records [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Reference Manual Vol. 1
Adding New Records
The FILE *INSERT command and the SQL INSERT command allow you to insert
new records into an HP ALLBASE/SQL table.
FILE *INSERT Command
You can insert a row into an HP ALLBASE/SQL base table with the FILE
*INSERT command in an HP ALLBASE/4GL logic block. The command has the
format:
FILE *INSERT file_name
where file_name is the HP ALLBASE/4GL name of a base table. This command
inserts the current record buffer contents into a base table as a new
record. You must specify that the file is available for update by
including a MODE *WRITE command in the same HP ALLBASE/4GL process.
Example 2 - Adding New HP ALLBASE/SQL Records
Process add_titles
1 MODE *WRITE titles
.
.
.
5 FILE *INSERT titles; ENTER 10
6 SQL commit
.
.
10 VISIT sql_error
The FILE command in this HP ALLBASE/4GL logic block inserts the current
contents of the record buffer for the file titles into the base table
whose name is specified on the dictionary file definition screen for the
HP ALLBASE/4GL file titles. If the record already exists, the optional
error command on the FILE command is executed and control passes to step
10.
SQL INSERT Command
You can also insert a new row into an existing a base table by using the
SQL INSERT command in an SQL logic block. The INSERT command must be in
the following format:
INSERT INTO table_name [(column_name ...)]
VALUES (SingleRowValues);
In this expression, table_name is the external name of the table. You
can use a fully qualified name of the form owner.table_name in this
command.
Example 3 - Adding New HP ALLBASE/SQL Records
This example shows the use of the SQL INSERT command to insert a new
record into a base table.
SQL Logic Block titles
INSERT INTO library.titles
(ISBN, TITLE, AUTHOR)
VALUES (:V-isbn_no,:S-title.addtitle, :S-author.addtitle );
COMMIT WORK;
This SQL logic block contains an INSERT command that inserts a new record
into the table library.titles. This command inserts the current values
of the HP ALLBASE/4GL variable V-isbn_no, and the current contents of the
screen fields title and author on the screen addtitle, into the
corresponding columns of the new record. Note that references to HP
ALLBASE/4GL screen fields in SQL logic blocks must use the fully
qualified screen field name. You cannot use references by number, or
relative number.
MPE/iX 5.0 Documentation