0

Add Record

Description

This part offers an easy way to insert a new record into a data table in the database.

Use

You can use this part to add new record to a data table in the database and return the row id of the inserted record. To insert multiple records use the Add Records part, or create a Loop to cycle through an array and use Add Record on each cycle.

Editor Fields

Tab Field Name Description/Use Type/Options Optional/Mandatory
Basic Data object This is the data object in which to store the id of the inserted record. Leave this field empty if your application does not require the returned row id. Text Optional
Basic Group This is the name of the collection in which the data object is stored. Text Optional
Basic Data source This is the name of the table into which the data should be saved. Text Mandatory
Basic Replace if already exists When this checkbox is checked, the system should update the existing record if it exists instead of inserting as a new record. Checkbox Optional
Basic Columns This is where you specify the column into which a record should be inserted and the value that should be inserted. The value to insert can be either a static value or an interpolated parameter from the session context. If you do not include the id column as one that should be added to the record, the system will automatically increment the table index.

Tip: Use the $(...) construction to reference a variable from your application as the value to be stored in the column; for example, $(firstname).

You can also specify a default value if the variable is null by using $(data_object:default-value); for example, $(company_name:not specified). For more information on inserting null values, see the table below in the Adding Null Values section.
Collection Mandatory
Basic Log data object This is the data object that stores error messages from the execution of the database parts: add data record, get data record, update data record, delete data record, and import values. If the log data object is specified, the system will store the error message and stack trace of a database part to the object in case of errors.

When used by multiple database parts, the Log data object stores the cumulative list of error messages from the different parts.
Text Optional
Basic Reset log data object When this is checked, the system will clear the error messages from the Log data object. Typically, this option should be checked in the first database part of a sequence of database parts. Checkbox Optional
Basic Skip on error When this is checked, the system will skip the execution of subsequent database parts linked to the same Log data object. Checkbox Optional

Adding Null Values

When dealing with empty or null values in data tables, it is important to remember that there is a difference between no value and a null value. In database terms a null value is a value that does not exist: the field does not contain a value of any kind (not even a blank value). A blank value is a real value: it just happens to be a string value containing 0 characters. When you are adding or updating a value in a data table, you need to determine if you want to add an empty value or a null value and how you do it depends on what data type the field is set to receive.

The table below details what the table will save based on the data field type; for example, if the field is a text field it is expecting free format text. If you do not enter a value in the field the system will enter a blank field. 

Data Type Value If you Enter No Value/Empty String If you Enter ‘NuLLeD’
Text Free format text Empty string NULL
Number A number. The system will thrown an error if the number is invalid (if you enter text, for example). NULL NULL
Date/DateTime A logicnets datetime (number). The system will throw an error if you enter an invalid number/value. NULL NULL
Collection Dataobject name, Lua data-structure code, OR $() pointing to a data object in the context that is a dataobject OR a Lua datastructure code NULL NULL

Here is an example of what you might add in a field and how that will save in the data table. You can see we left the firstname field blank. It is a text field so the system entered a blank value. Birthdate is a date/datetime field and we entered NuLLeD so the system made that a null field. Income is a number field, which we left blank, so the system made that a null value.

 

Configuration Options

There are no configuration options associated with this part.

Examples

Download and import one of the example projects in your workspace.

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 3 mths agoLast active
  • 61Views
  • 3 Following

Home