The database components allow conditional execution of a statement. To do this, you specify a test condition using the test attribute for the statement tag in the configuration XML file.

<statement name="main" test="...">
  ...
</statement>

In the above example, the value of the test attribute is a condition for the main statement and will be executed only if the specified condition evaluates to true. There are three types of parameters to be tested as listed below:

  • An incoming message property specified by $<message property name>. Not available in the Database communication point in Input mode.
  • An incoming message field specified by @<full path of a message field>. Not available in Input mode.
  • A database table column value specified by @<column name>. All column values returned by the parent statement can be tested.

The test attribute is used to specify a condition to execute a statement. A condition is either a function or an expression and should fall into one of the following forms:

  • NULL(param) - tests whether a parameter is null or the empty string.
  • NOTNULL(param) - tests whether a parameter is neither null nor the empty string.
  • EQUALS(param1, param2) or param = value - tests whether the parameter value equals the value to be tested.
  • NOTEQUAL(param1, param2) - tests whether the parameter is not equal to the value to be tested.
  • EQUALSIGNORECASE(param1, param2) - same as the "equals" test except this is a case-insensitive test.
  • NOTEQUALIGNORECASE(param1, param2) - same as the "not equals" test except this is a case-insensitive test.

The function name is not case-sensitive. Refer to Condition Editor for details.

Examples

test = "notnull(@ADT.location)"

This condition would be true if the incoming message has an ADT.location field and it is not null or an empty string.

In the following example, the Delete Record statement is executed if the processed value is not empty and the Update Record statement is executed if it is.

<statement name="Select Record">
  <sql>
    SELECT name, processed From personsTable
    WHERE name = @NK1.ContactPersonsName.FamilyName
  </sql>
  <statement name="Delete Record" test="NOTNULL(@processed)">
    <sql>
      ...
    </sql>
  </statement>
  <statement name="Update Record" test="NULL(@processed)">
    <sql>
      ...
    <sql>
  </statement>
</statement>

In the following example, both test conditions are identical and the condition would be true if the value of the table column named columnName is aaa. The column value should be selected from the parent statement as in the following configuration example.

test = "@columnName='aaa'"
test = "Equals(@columnName, 'aaa')"

In the following example, the Diagnosis statement is executed only if the dischargeEventId equals id001.

<statement name="DischargeEventBody">
  <sql>
    select IDENTITY as dischargeEventId
  </sql>
  <statement name="Diagnosis" test="@dischargeEventId='id001'">
    <sql>
      ...
    <sql>
  </statement>
</statement>