ALLBASE/SQL Reference Manual (36216-90216)

Chapter 11 457
SQL Statements E - R
INSERT
A new row is added to the PurchDB.Parts table based on the prepared INSERT
statement called CMD. Row values are provided at run time, and an EXECUTE statement
using two host variables is required to complete the INSERT.
EXECUTE CMD USING :PartNumber, :PartName;
5. Bulk insert using dynamic parameters with host variables
PREPARE CMD FROM 'BULK INSERT INTO PurchDB.Parts (PartNumber,
PartName)
VALUES(?,?);'
Multiple rows can be added to the PurchDB.Parts table. Row values are provided at run
time, and an EXECUTE statement using the address of a host variable array containing
dynamic parameter data and host variables containing the starting index and number
of rows to be inserted complete the INSERT.
EXECUTE CMD USING :DataBuffer, :StartIndex, :NumberOfRows;
6. Bulk insert or single row insert using dynamic parameters with sqlda_type and related
data structures
PREPARE CMD FROM 'BULK INSERT INTO PurchDB.Parts (PartNumber, PartName)
VALUES(?,?);'
One or more rows can be added to the PurchDB.Parts table. Row values are provided at
run time, and an EXECUTE statement using a descriptor area is required to complete the
INSERT.
Before issuing the execute statement, you must set certain fields in the descriptor area.
(The ALLBASE/SQL application programming guides contain detailed information
regarding this technique.) Then you describe the input to ALLBASE/SQL.
DESCRIBE INPUT CMD INTO Sqlda;
EXECUTE CMD USING DESCRIPTOR Sqlda;