Insert Multiple Records

This server behavior performs multiple database record insert when an event on the page is triggered. It inserts the record into the selected database table using the defined connection.

A form specified on the page contains the form elements necessary to pass data specific to columns within the database for records to be inserted. That form is contained within the DataAssist Repeat Selection server behavior, which repeats the form for a specified number of iterations, incrementing the names of the repeated form elements as well This allows for the display and possible insert of a corresponding number of simultaneous record inserts using the multiple iterations of the insert form.

It is necessary to define how the inserts are triggered on the page, and how to deal with an iteration of the form that does not contain information to be inserted for a specific column. Determine where the page is to redirect upon completing the inserts, and whether or not to preserve the querystring and pass it to the redirect page.

You must also map the form fields in your repeated insert form on the page to the database columns that will contain the record data, and ensure that they format the inserted data according to the correct datatype for the given column.

Note: This server behavior does not work with forms that use a multipart encoding type (i.e. enctype="multipart/form-data")

Access

The Insert Multiple Records server behavior is accessible in the following location:
  • Server Behaviors panel > Plus icon (+) > WebAssist > DataAssist > Insert > Multiple Record Insert

General

Trigger

Determine the page event or trigger used to insert the entered record information to the database:

Trigger: Refers to a request, session variable, or other dynamic data events. The existence of a value for the specified variable triggers the insert on a given page. A request object (such as a hidden form element) or a session variable must be submitted or passed to the page that has the server behavior applied to it in order for the insert to execute. Available triggers are:
  • Any Form Post: Any form posted to the current page that the server behavior is applied to triggers the data insert
  • Before Page Load: The data insert is triggered when the current page that the server behavior is applied to is loaded.
  • On Form Submit: Any form submitted on the same page that the server behavior is applied to trigger the data insert.
  • Button [button name] pressed: The server behavior is triggered if the specified button on the page is clicked.
  • Dynamic Data: Server-side code can be specified in the dynamic data interface (accessed through the lightning bolt) to create a trigger specific to your needs if one in the list does not meet your requirements.
Repeated form: Select a form on the page that is contained within a region encompassed by the DataAssist Repeat Selection server behavior.

Skip if empty: Skips the insert of a specific record If no value is passed for the database column selected here. If you wish to insert placeholder records into your database to be populated at a later time, but that may not contain data currently, you have the option of selecting Always insert, which will allow the insert of data containing blank fields, so long as the corresponding database columns have default values specified in the database on insert, or can accept NULL values.

Database

The following criteria is necessary to properly configure your database information for use with this server behavior:

Connection: Selects the database connection used to connect to the database for your application. Select from a list of available connections defined prior, or click the Define button to configure a database connection.

Table: Selects the table within the chosen database that contains the records being inserted.

After insert

Specifies the destination page redirected to upon completing the records insert, and determines if a querystring that existed prior to the insert should be perpetuated to that page.

Go to: Sets the redirect location that is loaded upon insertion of the record

Pass original querystring: If a query is currently maintained in your session from prior to the insert, checking this box will pass that querystring on to the redirect page.

Bindings

Map the repeated form elements or other source of specific record data to the database column receiving it. Select the correct data type for the given database column to ensure data integrity.



Insert values

Note: Autonumber database columns should not be updated during the insert process.

Data type: Sets the data type for the selected database column the data is inserted into. This is necessary to ensure data is inserted using the correct data formatting criteria. The following is a list of available data types to select, but please refer to your database to ensure proper correlation:
  • Text: Only accepts text values.
  • Numeric: Only accepts numeric values.
  • Date: Accepts date values using standard SQL syntax.
  • Date MS Access: Accepts date values from MS Access databases.
  • Checkbox: Y,N: Defines checkbox values in a database using Y and N.
  • Checkbox: 1,0: Defines checkbox values in a database using 1 and 0.
  • Checkbox: -1,0: Defines checkbox values in a database using -1 and 0.
  • Checkbox: MS Access: Defines checkbox values in a MS Access database.
Value: Sets the source of the data to be inserted for the selected column. Typically, this will be a form element, but you may also use server-side code to define the inserted information.