Class TInsertSqlStatement

All Implemented Interfaces:
IRelation, Visitable, Iterator<TSourceToken>

SQL insert statement.

TCustomSqlStatement.getTargetTable() returns the table or view that receive the data.
getColumnList() returns the list of columns in target table if specified.
Usually, the data comes from a value clause, you can get those values from getValues().
Always checking getInsertSource() before fetch the data source which may various from value clause to subquery and other forms. Below are some data source types:
Examples:
 INSERT INTO Production.UnitMeasure (Name, UnitMeasureCode,ModifiedDate)
 VALUES (N'Square Yards', N'Y2', GETDATE());
 
Table name: Production.UnitMeasure. Fetched from TCustomSqlStatement.getTargetTable() or the first element of TCustomSqlStatement.tables
column list: (Name, UnitMeasureCode,ModifiedDate). Fetch from getColumnList()
value list: (N'Square Yards', N'Y2', GETDATE()). Fetch from getValues()
 INSERT INTO dbo.EmployeeSales
 SELECT 'SELECT', sp.BusinessEntityID, c.LastName, sp.SalesYTD
 FROM Sales.SalesPerson AS sp
 INNER JOIN Person.Person AS c
 ON sp.BusinessEntityID = c.BusinessEntityID
 WHERE sp.BusinessEntityID LIKE '2%'
 ORDER BY sp.BusinessEntityID, c.LastName;
 
select query in above insert statement can be fetched from getSubQuery()
See Also:
  • TCustomSqlStatement.cteList
  • TCustomSqlStatement.targetTable
  • TCustomSqlStatement.outputClause
  • TCustomSqlStatement.returningClause