OQL Insert corresponds to the Insert Statement of SQL-92 as follows:
l Insert records from the returned of a select statement:
|
var qryCustomer : ISelectQuery; qryOrder : ISelectQuery; insert : IInsertQuery; begin qryCustomer := TSelectQuery.Create; qryCustomer .Select(NW.Customer.CustomerID) .From(NW.Customer) .Where( OQL.Criteria(NW.Customer.ContactTitle).EQ('Owner') ); qryOrder := TSelectQuery.Create; qryOrder .Select(NW.Order) .From(NW.Order) .Where( OQL.Criteria(NW.Order.CustomerID).In_(qryCustomer) ); insert := TInsertQuery.Create; insert .InsertInto(NW.Order) .Select(qryOrder); end; |
|
== Equal to the following SQL [MS SQL Server] == |
|
INSERT INTO
[Orders] SELECT [Orders].* FROM [Orders] WHERE
[Orders].[CustomerID] IN
(
SELECT [Customers].[CustomerID]
FROM [Customers]
WHERE
[Customers].[ContactTitle] = 'Owner'
) |
l Insert records (enumerated constant):
|
var insert : IInsertQuery; begin insert := TInsertQuery.Create; insert .InsertInto(NW.Order) .Fields(NW.Order.ShipCity)._(NW.Order.ShipVia) .Values(' end; |
|
== Equal to the following SQL [MS SQL Server] == |
|
INSERT INTO
[Orders] (
[ShipCity] , [ShipVia] ) VALUES (
' ) |
Related Topics