Insert - Add a record to a database table
This action adds a new record to a database table.
Triggers
<Record> (non-repetitive trigger [required]): The record to add
(a data structure with the record's fields).
- The database table is identified by the tableName property
of the data type of <Record>.
- The structure of the database table is automatically inferred from the structure
of the added record:
- If the inserted data structure contains only leaf data elements
(strings, numbers, dates etc.), then each leaf is mapped to
a column (field) in the database table. For example, a numeric Id
leaf will be mapped to a numeric field named Id.
If the leaf name contains blanks, these are changed to undescores
(e.g. a leaf named First Name will be mapped to a field
named First_Name).
- If the inserted data structure contains composite data elements,
then only leaf data elements are mapped to columns in the database table.
The name of each database field is the concatenation of the names of
all the data elements along the path to the corresponding leaf data element
(e.g. if the data structure contains a data element named Sender,
which contains leaves Id and Name, then the datbase table
will contain two corresponding fields: Sender_Id and Sender_Name).
You may skip the name of a ceratin data element along the path by settings
its excludeFromFieldName property to true (e.g. if the
Sender data element is excluded, then the database fields will be
named Id and Name).
- To specify that a certain field is a primary key of the database table,
set the primaryKey property of the corresponding leaf data
element to true.
<Data Source> (non-repetitive trigger [not required]): Name of data source to use
(if different from the default data source; see Connecting to an External Database).
<Table Name> (non-repetitive trigger [not required]): Name of the database table
(if different from the tableName property of the data type of <Record>).
<Auto Commit> (non-repetitive Boolean trigger [not required]): Indication whether to
interact with the database in auto-commit mode.
- If <Auto Commit> exists and a Yes value is received, the database action is performed
in auto-commit mode, regardless of any active transaction
(see Database Transaction Support in Tersus).
Exits [none required]
<Inserted> (non-repetitive exit [not required]): The input data structure,
in case the record has been added to the table.
<Duplicate> (non-repetitive exit [not required]): The input data structure,
in case the record has not been added (as the table contained another record with the same key).
Notice: The two exits represent two mutually exclusive possibilities:
<Inserted> is activated only if the record has been
added to the table;
<Duplicate> is activated only if it has not been added.
You can use the action with just one of the exits (if there is only one case that
is interesting) or with both exits. You can also use the action with none of them
(if none of the exits exists, you can, but not have to, add a <Done> empty exit, which will be activated
in both cases).
Usage Example
"Submit" (at the end of stage 3 of the tutorial):