Batches of SQL Statements
VALUES (2002, 1001, {fn CURDATE()}, 'Garcia', 'OPEN');
INSERT INTO Lines (OrderID, Line, PartID, Quantity)
VALUES (2002, 1, 1234, 10);
INSERT INTO Lines (OrderID, Line, PartID, Quantity)
VALUES (2002, 2, 987, 8);
INSERT INTO Lines (OrderID, Line, PartID, Quantity)
VALUES (2002, 3, 566, 17);
INSERT INTO Lines (OrderID, Line, PartID, Quantity)
VALUES (2002, 4, 412, 500)
SELECT * FROM Customers WHERE CustID = @CustomerID
SELECT OrderID FROM Orders
WHERE CustID = @CustomerID AND Status = 'OPEN'
VALUES (?, ?, ?, ?)
The different types of batches cannot be mixed in an interoperable manner.
That is, how an application determines the result of executing an explicit batch
that includes procedure calls, an explicit batch that uses arrays of parameters,
and a procedure call that uses arrays of parameters is driver
Explicit batches. An explicit batch is two or more SQL statements separated by semicolons (;).
For example, the following batch of SQL statements opens a new sales order.
This requires inserting rows into both the Orders and Lines tables. Note that
there is no semicolon after the last statement.
Procedures. If a procedure contains more than one SQL statement, it is considered to be
a batch of SQL statements. For example, the following SQL Server–specific statement creates a procedure that returns a result set containing
information about a customer and a result set listing all the open sales orders
for that customer:
Arrays of parameters. Arrays of parameters can be used with a parameterized SQL statement as an
effective way to perform bulk operations. For example, arrays of parameters can
be used with the following INSERT statement to insert multiple rows into the Lines table while only executing a
single SQL statement: