Insert-SQL
This form of INSERT is actually useful—unlike the Xbase version. It adds one or more records to a specified table, filling in fields at the same time.
Usage |
INSERT INTO cFileName [ ( cFieldList ) ] VALUES ( uValueList ) INSERT INTO cFileName FROM ARRAY aValueArray | MEMVAR |
Parameter |
Value |
Meaning |
cFileName |
Character |
The name of the table getting new records. |
cFieldList |
Character |
A comma-delimited list of fields for which values are specified. |
Omitted |
Values are specified for all fields. |
|
uValueList |
Assorted |
A comma-delimited list of values to place in the new record. |
aValueArray |
Array |
An array containing values to place in the new record. |
Watch out when you want to insert data from one table into another. The INSERT command changes work areas behind the scenes before it evaluates the new field values, so you need to add the alias to fields from other tables. Similarly, if you have a variable with the same name as a field in the table to which you're adding a record, be sure to use the m. notation. |
Example |
* Add a record to the Customer table. INSERT INTO Customer (Customer_Id, Company_name, Contact_name) ; VALUES ("MSFT","Microsoft","Bill Gates") * Create and save a new record. USE SomeTable SCATTER MEMVAR BLANK * Let the user edit the record. INSERT INTO SomeTable FROM MEMVAR |
See Also |
Append, Append From Array, Gather, Insert, Replace, Set Fields |