SORTED BY

SORTED BY

Sorts the members of the set produced by the main command.

Syntax

SORTED BY «expression [ASCENDING|DESCENDING]»

Parameters

expressionAn expression that identifies a field to be used as a sort key. Complex expressions must be enclosed in parentheses.
ASCENDING or DESCENDINGSpecifies how the sort on the associated key is to be performed.
ASCENDING (default)
Sorts in “alphabetical order” (A-Z, 0-9).
DESCENDING
Sorts in “reverse alphabetical order” (Z-A, 9-0).

Comments

The sorting clause determines the order in which the selected records are to appear in the set. The fields to be used as sort keys (identified by each expression) must be part of the set produced by the main command.

If you omit the sorting clause, the software determines the order of the records.

Note: Existing result sets can also be sorted after selection – with the SORT command.

Example

list all Employees sorted by Department descending FirstName LastName

The preceding command lists all Employees by department (in descending order) and, within department, by first and last names (in ascending order).

report from Invoices
sorted by {$month(InvoiceDate)-5
where $month(InvoiceDate) >= 6,
$month(InvoiceDate)+7}
:
endreport

The preceding program fragment reports invoices in order by fiscal month, assuming that the fiscal year begins in June.

See Also

SORT

UNRELATED

UNRELATED

In a set specification, selects non-matching members of an EntitySet, a relationship with fields, an application document, or a result set.

Syntax

object (UNRELATED)

Parameters

objectThe name of an EntitySet, a relationship with fields, a form, a structured application document, or a set. Can be a role name for an EntitySet or relationship with fields.

Comments

In a set specification, UNRELATED selects all records in object that do not satisfy the relationship condition expressed in the set specification.

UNRELATED can be used only once in a set specification.

This function is related to the theoretical partial outer join operation.

Example

> find all Employees (unrelated) WorkIn Departments

> list all
LastName  FirstName  DeptNum  DeptName DeptNum
Johnston  Leslie   D07
Nelson    John
Kelly    Pat

The preceding command finds all employee records that contain no DeptNum, or contain a DeptNum for which there is no corresponding department record. Missing values are undefined ($Null).

find all Employees WorkIn Departments (unrelated) keep Departments

The preceding command creates a list of all departments that have no employee records associated with them.

find all Managers (unrelated) Manage Employees

Finds all employees that do not manage anyone. (For a contrasting example, see COMPLETE.)

See Also

– (Dynamic Rename)

COMPLETE

USING

$DeadlockReason

Indicates the reason that a deadlock condition occurred.

Syntax

$deadlockreason

Return Value

A character string. Cannot be reset by an application program.

Description

$DeadlockReason contains one of the following reason codes for the current deadlock condition:

CodeReason
0transaction completed normally
1transaction terminated due to time out
2transaction terminated due to transaction recovery
3not in use
4attempt to do an update in a read transaction
5transaction terminated as a result of deadlock
6lock request outside a transaction (warning only)
7problem converting operating system lock (transaction terminated)
8no free file table entry (transaction terminated)

See Also

SET DOCUMENT FORMAT

System Variables

$Null

A “null” value for comparison.

Syntax

$null

Value

“Null” (a state of valuelessness). Cannot be reset by an application program.

Description

The “null” property. $Null can be written without the dollar sign.

When certain atomic expressions (variable name, field name, form field name, or formal parameter name) are used before being assigned values, or if the values are unknown, those expressions are considered to be $Null.

$Null is a property indicating a state of valuelessness; $Null is not itself a value. The null string is a value and is therefore not the same as the $Null property.

An arithmetic or functional expression that includes a $Null argument or operand always evaluates to $Null.

A logic expression that includes a $Null operand always evaluates to $False.

Because $Null is not a value, you cannot use the conditional operators = (Equals) and <> (Not Equals) to determine if an expression is $Null. Instead, the operator IS [NOT] [$]NULL is used as shown in the following example:

Salary is $null
Salary is null
Salary is not $null
Salary is not null

Note: You can write $Null without the dollar sign.

Example

if Salary is $null
 let Salary = StartingSalary
 ... commands ...
endif

See Also

$False

$True

IS [NOT] [$]NULL

Checks a value to see if it is $Null.

Syntax

expression IS [NOT] $NULL

Parameters

expressionAny expression.

Return Value

Logical.

Comments

An IS $NULL comparison is logically true if expression is valueless (unassigned). If expression has been assigned any value (including the null string), then the comparison is logically false.

An IS NOT $NULL comparison is logically true if expression has been assigned any value (including the null string). If expression is valueless (unassigned), then the comparison is logically false.

$NULL can also be written as NULL.

Example

To find all employees whose records have no value recorded in the Age field, and then change that value to 39, enter

change all Employees where Age is $Null let Age = 39

See Also

About Boolean Expressions

About Conditional Expressions

WHERE

Controls the evaluation of other expressions.

Syntax

expression1 WHERE expression2

Parameters

expression1A value expression.
expression2A logic expression using conditional and Boolean operators.

Return Value

If expression2 is logically true, the value of expression1; otherwise, $Null.

Example

let i = { 1 where Age < 10,
2 where Age between 10 and 30,
4 where Age > 50, 3 }

Assigns a value to the variable i based on Age.

compute Employees evaluate
(let TotSal = $total(Salary where LastName = “Smith”)

Finds the total of the salaries of all employees named Smith.

See Also

About Boolean Expressions

About Conditional Expressions

Conventions

LET

Special Expression Formats

[NOT] LIKE

Matches an expression to a pattern.

Syntax

expression [NOT] LIKE pattern

Parameters

expressionAn expression that evaluates to a character string.
patternAn expression that evaluates to a character string. Pattern must consist of combinations of letters, digits, symbols, and the special wildcard characters % and _.

Return Value

Logical.

Comments

A LIKE comparison is logically true if expression matches patterns.

A NOT LIKE comparison is logically true if expression fails to match pattern.

Example

compute Employees where LastName like "_a%n"

Processes all records whose LastName values are three characters or more, the second character being an a, and the last character being an n.

find Parts where PartNo like "_ _\_%"

Finds all parts whose part numbers have an underscore as the third character.

find Parts where PartDesc like "%\\%"

Finds parts whose part description contains a backslash.

See Also

About Conditional Expressions

[NOT] IN

Compares one value to a list of values.

Syntax

expression [NOT] IN («expr»)

Parameters

expressionAn expression that evaluates to either a number or a character string.
exprA list of expressions whose values are to be compared to expression. Members of the list are separated from one another by commas.

Return Value

Logical

Comments

An IN comparison is logically true if expression is equal to at least one of the values in the specified list.

A NOT IN comparison is logically true if expression is not equal to any of the values in the specified list.

In either case, the comparison ends as soon as a logically true instance is found.

Example

The conditional expression that follows is logically true if the value of AirPollutants matches any of CFC, CO, or NOX.

AirPollutants in (" CFC","CO"," NOX")

The conditional expression that follows is logically true if the value obtained from either TicketAmt*5 or Receipts*10 equals 10,000.

10000 in ( TicketAmt * 5,Receipts * 10)

See Also

About Conditional Expressions

ZIM Comment Block << >>

(Program template delimiters)

<< your code >>

Quickly marks a large block of code that you want to prevent from running or that you want to be generated by the GENERATE command by putting the delimiters at the start and end of an output section in a template program.

Syntax

Place a two less than characters before the start of the code.

<< 
code / statements

>>

Place a two greater than characters at the end of your code.

Parameters

code \ statements

 

one or more command statements, typically using macros, to send to the current output destination when the program containing them is processed with a GENERATE command

 

Comments

The program template delimiters, << and >>, must appear alone on a physical line in the application document. When the program is executed, parsed, or compiled, the statements between the delimiters are ignored.

When the program is run under the GENERATE command, the statements are sent as output, after macro substitution, to the current output device.

Example

… commands1 …
<<
… commands2 …
>>
… commands3 …

Under normal execution, commands1 and commands3 execute normally; commands2 are ignored.

When the program is parsed or compiled, commands1 and commands3 are parsed or complied in the usual manner; commands2 are ignored.

When the GENERATE command is used, commands1 and commands3 execute normally; commands2 are sent as output, after macro substitution, to the current output device.

< > (Macro name delimiters)

Marks the start and end of a macro name in an application program.

Syntax

<name>

Parameters

nameThe name to be assigned to a global macro, or a digit from 0 to 9 referring to one of the local macros belonging to the current macro program.

Comments

A macro is a dynamically declared name that represents a character string. When a macro call is encountered in an application program, the macro call is replaced by the current character value of the macro.

A macro acquires values in one of two ways: implicitly, when the software encounters a call to a previously unknown global macro or unassigned local macro, or explicitly, in a LET or INPUT statement or a call to a local macro.

Example

let <EntSet> = "ENTS"
let <Name> = "EntName"

Defines the global macro to represent the string ENT. Then the statement

list #<EntSet> format #<Name>

is interpreted as

list ENTs format EntName

See Also

Conventions

How To Construct Logic Expressions

How To Use Logic Expressions

en_CAEnglish