User Tools

Site Tools


WRITE

Guide Section: Processing Object Data
EASAP Tree:
DATA PROCESSING or EVENT PROCESSING or PROCESSES > DATABASE


WRITE performs a write action in the DATABASE specified in its parent DATABASE.

A WRITE may be in one of three forms:

  • Insert new data into the database
  • Update existing data with new data
  • Delete existing data in the database

WRITE uses the Structured Query Language (SQL) to define a SQL query in either Text: or File:

The SQL query must start with an INSERT, UPDATE or DELETE statement.

An Author using a DATABASE must be proficient with SQL and have an understanding of the content of their database.


the Parameters: parameter

Each question mark ' ? ' within the SQL statement will take data from a correseponding element in Parameters: (comma separated LISTs and/or SCALARs are allowed).

This might help to to modify multiple rows or SQL statements with a single object.

Another benefit of using Parameters: might be to avoid parsing errors and unexpected behavior around executing SQL statements made up of text that include a single quote sign ( ' ), other special characters, or using LIST or SCALAR references.

There must be the same number of LISTs specified in the Parameters: parameter as there are ' ? ' characters in the SQL statement.


INSERT Statement

The basic form of an INSERT statement is: INSERT INTO table_name (column_names) VALUES (actual_values)

Where table_name will be a table found in the database, column_names will be a comma separated list of columns found in the specified table, and actual_values will be a comma separated list of values to be inserted into the specified columns.

Additional SQL syntax, such as WHERE and SELECT clauses, can be included in your SQL query.

To insert multiple rows with a single WRITE, use Parameters:


UPDATE Statement

The basic form of an UPDATE statement is: UPDATE table_name SET column_name = actual_value WHERE expression

Where table_name will be a table found in the database, column_name will be a column found in the specified table, and actual_value will be the value to change the existing values to in the specified column.

A WHERE clause is shown above to demonstrate how to narrow the UPDATE down to only rows in the specified column in which the expression evaluates to a true value. Additional SQL syntax, such as SELECT clauses, may be included in your SQL query.


DELETE Statement

The basic form of a DELETE statement is: DELETE FROM table_name WHERE an_expression

Where table_name will be a table found in the database and an_expression is logical expression that will cause entire row(s) to be deleted when it evaluates to a true value.

Unlike the SQL used in a READ, the SQL used in a WRITE is potentially destructive, especially the DELETE statement, because it makes changes to the database. For instance a DELETE statement without a WHERE clause will delete all data in the tables specified. Therefore, you should always test SQL for a WRITE thoroughly on a test database before use on a production database.

WRITE
Optional Parameters:
Text:Enter text of a SQL query that begins with an INSERT, UPDATE, or DELETE statement
SCALAR and/or LIST references allowed
File:Select a filename containing text of SQL query that begins with an INSERT, UPDATE, or DELETE statement
SCALAR reference allowed
Parameters:Enter a comma-separated LISTs and/or SCALARs, each will replace a substitute for a ' ? ' character in the SQL query
Delimiter:Set a character to delimit any LIST or SCALAR references in Text: or File:
Default: %
Encoding:Select a text encoding used in File:
Default: US-ASCII
Diagnostics:Enter a name for a new SCALAR to contain the contents of any database error message
Setting this disables the effect of an DATABASE ACTION > On Error:
Error Occurred:Enter name for a new SCALAR to contain a status string, ERROR or NO ERROR, to indicate a successful query
Setting this disables the effect of DATABASE ACTION > On Error:
Empty as Null:Treat any 'empty single quote pair' or 'two adjacent commas' as a database NULL value
Default: FALSE or TRUE
This will change the VALUES clause:
some_text,'',some_text,,some_text
goes to:
some_text,NULL,some_text,NULL,some_text