INSERT statement

The INSERT statement adds a new row to an external database.

Syntax

The optional column name list identifies a list of columns in the target table into which to insert values. Any columns not mentioned in the column name list have their default values inserted.

A runtime error might be generated if problems occur during the insert operation. For example, the database table might have constraints defined that the insert operation might violate. In these cases, an exception is thrown unless the node has been configured to modify this behavior.

Examples

The following example assumes that the dataSource property on the Database node has been configured, and that the database identified by that data source has a table called TABLE1 with columns A, B, and C.

Given a message that has the following generic XML body:
<A>
 <B>1</B>
 <C>2</C>
 <D>3</D>
</A>
The following INSERT statement inserts a new row into the table with the values (1, 2, 3).
INSERT INTO Database.TABLE1(A, B, C) VALUES (Body.A.B, Body.A.C, Body.A.D);

Handling database errors

For information about handling database errors, see Capturing database state.

Related concepts
ESQL

Related tasks
Developing ESQL
Capturing database state

Related reference
Syntax preference
ESQL statements