


The SQL INSERT command is used to load one or more rows into an existing table, thereby updating the data in your Vision or relative files.
Syntax:
INSERT INTO <table-name>
[(<field-list>)]
VALUES (<values-list>)
<table-name>
is the name of the table where records must be inserted.
<field-list>
is an optional list of fields to which you want to assign a value. This list must be written according to the following syntax:
<field-name>
[,[<field-name>] [, ...]]
Omitting this list specifies all the
fields of the table, using the same order
as they are defined.
<value-list>
is a list of literals. The value of these literals is assigned to the fields specified in <field-list>, according to the order in which they are listed. For this reason the number of elements of both the lists must be equal. At the same time, the type of field (alphabetic, numeric, etc.) must be compliant with the value of the literal.
<value-list> has the following format:
<literal>
[,[<literal>] [, ...]]
Example:
VALUES ("Acucorp Inc.", "8515 Miralani Drive",
92126).
INSERT INTO CLIENTS
(COMPANY-NAME, ADDRESS, ZIP-CODE)
This command creates a new row in the
table named CLIENTS, and assigns the
value "Acucorp Inc" to the field COMPANY-NAME, the value
"8515 Miralani Drive" to
ADDRESS, and 92126 to ZIP-CODE. As required by the syntax, the number
of
fields (three) corresponds exactly to the number of values.
The following examples are incorrect.
VALUES ("Acucorp Inc.", 92126, "8515 Miralani
Drive",).
INSERT INTO CLIENTS
(COMPANY-NAME, ADDRESS, ZIP-CODE)
The positions of values don't match
with the positions of the fields. 8515
Miralani Drive is an alphanumeric value, while ZIP-CODE is numeric. An
error
message would result.
VALUES ("Acucorp Inc.", "8515 Miralani Drive").
INSERT INTO CLIENTS
(COMPANY-NAME, ADDRESS, ZIP-CODE)
In this example, the number of values
does not correspond to the number of
fields. An error message would result.