Variable usage and null values

Anytime you use a custom variable in query you should ensure that it does not have a null value. Null values in query variables can cause full table scans which lower your system's performance.You can avoid null values in custom variables by using the following methods:

  • Use the nullsub() function to replace the null value with a default value.
  • Replace a custom variable with system variable. System variables obtain a value when a user logs in to the system or accesses a particular application.

For example,suppose you create a custom variable $name to store a contact's name. You could provide a default value for the variable with the following expression.

$name=nullsub($name, contact.name in $L.file)

In this case, the default value will become the contact name listed in any file that uses this contact.name field. If query does not have access to the contact.name field value, you may consider hard-coding the default value, but the utility of such a hard-coded value may be limited.

Alternatively, you may want to use an existing system variable such as $lo.user.name or $lo.ufname to provide the name of current operator.

Related concepts

Indexing
Query operators
Function usage