D -- Logic Commands

DateConvert

Converts dates between date formats. The segment's Date Format property determines the date format.

DateConvert Complex Form

Converts the value of a variable, storing the result in a series of built-in segment attributes with the prefix Glb.DC_, or in a single variable in a specified format.

DATECONVERT date_variable [ {+ | -} 
date_varible ] FORMAT format  [ variable FORMAT 
format | EDITONLY ] [GS status]
Option Description

date_variable

The input date. If it is a number-primitive, then its format must be one of the number formats listed below.

{+ or -} date_variable

The offset, measured in days, of the result date from the input date.

(FORMAT or FMT) format (first)

The format of the preceding input date. The format parameter must be one of the formats listed below.

variable

A string-primitive or number-primitive variable to receive the result. If it is a number-primitive, then its format must be one of the number formats listed below.

(FORMAT or FMT) format (second)

The format of the preceding result variable. The format parameter must be one the formats listed below.

After executing with this clause, the Glb.DC_ built-in segment attributes are undefined.

EDITONLY

Validates the date variable.

After executing with this command option, the Glb.DC_ built-in segment attributes are undefined.

GS status

Indicates an invalid date using the specified variable.

Valid formats are:

DAYNUM

UK-ALPHA

US-ALPHA

IN-ALPHA

DD-MM-YY

DD-MM-CCYY

DD-MMM-YY

DD-MMM-CCYY

DDMMMYY

DDMMMCCYY

DDMMYY

DDMMCCYY

MM-DD-YY

MM-DD-CCYY

MMDDYY

MMDDCCYY

MMM-DD-YY

MMM-DD-CCYY

MMMDDYY

MMMDDCCYY

YY-MM-DD

CCYY-MM-DD

YY-MMM-DD

CCYY-MMM-DD

YYDDD

CCYYDDD

YYMMDD

CCYYMMDD

YYMMMDD

CCYYMMMDD

TODAY

WEEKNO (result only)

DateConvert Simple Form

Converts Glb.Total as either the source or destination of a relative day number, based upon the fixed date of January 1, 1957. If a base year other than 1957 is required, the DateConvert Complex Form should be used. The DateConvert simple form does not provide correct conversions for dates from the year 2057 (more than 100 years after the base year).

DATECONVERT { TODAYNUMBER | TODATE | TOALPHA } variable [ GS status ]
OptionDescription

TODAYNUMBER

Converts the following date variable to a relative day number, and stores the result in Glb.Total.

TODATE

Converts the relative day number from Glb.Total to a date, and stores the result in the following date variable.

TOALPHA

Converts the relative day number from Glb.Total to a date, and stores the result in the following date variable.

variable

A string-primitive or number-primitive variable. For both the ToDate and ToAlpha command options, the primitive of this variable determines the format of the result date.

GS status

Indicates an invalid date using the specified variable.

Detach

Moves text from an input value into a result variable of the same primitive type.

DETACH expression variable [ { POSITION | START } expression ] [ DELIMITER expression ]
Option Description

expression

A string value. It must share the same primitive as the following qualifier and the delimiter expression (if specified).

variable

A string-primitive variable. It must share the same primitive as the preceding expression, and the following delimiter expression (if specified).

(Position or POS or PO or Start) expression

Specifies the position in the string expression of the first character of the substring to detach.

If not specified, 1 is used as the starting position, that is the beginning of the string.

The expression start value can be a number-primitive attribute, variable, or literal. It can be signed or unsigned but can not have decimals.

If an attribute is used to specify the starting position, its value will be updated. The new value is the position of the first non-delimiter character following the delimiter in the string expression.

(Delimiter or DELIM) expression

Specifies the delimiting character of the substring to detach (the character following the last character of the substring). Can be a string or numeric value. If a numeric value is used, it is converted to text.

If not specified, a space character is used as the delimiter value.

The expression delimiter value can be a string-primitive variable or literal.

Determine Variants

The Determine logic command variants read records into memory from the database through a profile or, if using the Determine Actual logic command variant, an extract file or directly from a database table.

The logic command variants determine how records are read into memory, and how many are read. Once a record is in memory, it can be manipulated by logic.

Determine Actual

Can be used in three variants; the database variant reads records from the database, the extract file variant reads records from an extract file, and the SQLScript variant runs embedded SQL commands in an SQLScript.

Database Variant

Reads persistent class records into memory from the database, with or without using a profile.

DETERMINE ACTUAL <variant> [ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT

<variant> := <databaseVariant> | <extractFileVariant> | <sqlVariant>
<databaseVariant> :=  <iterator> [ SERIAL ] [ SECURE | KEYONLY ] [ MULTI records ]
<iterator> := <object> | <profile>
<object> := object_name
<profile> := object_name.profile_name( argument [ ,...n ] )
Option Description

iterator

The profile or persistent class to read. If a class is specified, records are read in the order in which they occur in the table for that class.

Profile needs to be specified in order to read a record from a class in profile order.

SERIAL

Increases efficiency by retaining pointers.

SECURE

Facilitates record locking of the database in an applications that do not force integrity.

KEYONLY

This command option is not supported on applications deployed to Windows.

MULTI records

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

Extract File Variant

Reads class records into memory from an extract file.

DETERMINE ACTUAL <variant> [ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT
<variant> := <databaseVariant> | <extractFileVariant> | <sqlVariant>
<extractFileVariant> :=  extract_file EXTRACTEDAS { records | EVENT }
RETAINEDAS file_name
Option Description

extract_file

The extract file to read. This extract file must have been previously saved using an Extract logic statement.

(EXTRACTEDAS or EAS) records

Reads records from the extract file as the specified class.

(RETAINEDAS or RAS) file_name

Saves the extract file (for example, for use in other reports) as the specified file name.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

SQL Script Variant

Runs embedded SQL commands in an SQLScript. This command is variant is not applicable for systems based on theMCP platform.

DETERMINE ACTUAL <variant> [ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT
<variant> := <databaseVariant> | <extractFileVariant> | <sqlVariant>
<sqlVariant> :=  sql_script
Option Desciption

sql_script

The SQLScript to run.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

Determine Back

Reads persistent class records into memory from the database in reverse profile order, starting back from the specified key values.

DETERMINE BACK <iterator> [ SERIAL ] [ SECURE | KEYONLY ] [ MULTI records ] [ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT

<iterator> := <object> | <profile>
<object> := object_name( argument [ ,...n ] )
<profile> := object_name.profile_name( argument [ ,...n ] )
OptionDescription

iterator

The profile or persistent class to read. If a class is specified, records are read using the class's default profile.

,…n

The key values to start reading back from.

SERIAL

Increases efficiency by retaining pointers.

SECURE

Facilitates record locking of the database in an applications that do not force integrity.

KEYONLY

This command option is not supported on applications deployed to Windows.

MULTI records

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

Determine Every

Reads persistent class records that match the specified key values into memory from the database.

DETERMINE EVERY <iterator> [ SERIAL ] [ SECURE | KEYONLY ] [ MULTI records ] [ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT

<iterator> := <object> | <profile>
<object> := object_name( argument [ ,...n ] )
<profile> := object_name.profile_name( argument [ ,...n ] )
Option Description

iterator

The profile or persistent class to read. If a class is specified, records are read using the class's default profile.

,…n

The key values to start reading back from.

SERIAL

Increases efficiency by retaining pointers.

SECURE

Facilitates record locking of the database in an applications that do not force integrity.

KEYONLY

This command option is not supported on applications deployed to Windows.

MULTI records

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

Determine From

Reads persistent class records into memory from the database in profile order, starting from the specified key values.

DETERMINE FROM <iterator> [ SERIAL ] [ SECURE | KEYONLY ] [ MULTI records ]
[ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT

<iterator> := <object> | <profile>
<object> := object_name
<profile> := object_name.profile_name( argument [ ,...n ] )
Option Description

iterator

The profile or persistent class to read. If a class is specified, records are read using the class's default profile.

,…n

The key values to start reading back from.

SERIAL

Increases efficiency by retaining pointers.

SECURE

Facilitates record locking of the database in an applications that do not force integrity.

KEYONLY

This command option is not supported on applications deployed to Windows.

MULTI records

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

Determine Group

Reads persistent class records into memory from the database using a profile, between specified start and end key values.

DETERMINE GROUP <iterator>  { FROM | BACK } ( [ argument [ ,...n ] ] )
[ UNTIL ( argument [ ,...n ] ) ] [ SERIAL ]
[ SECURE | KEYONLY ] [ MULTI records ] [ GS status ]
   <logic_block>
END | ENDEXIT | ENDNOPRINT

<iterator> := <object> | <profile>
<object> := object_name
<profile> := object_name.profile_name( argument [ ,...n ] )
OptionDescription

iterator

The profile or persistent class to read. If a class is specified, records are read using the class's default profile.

,…n

The key values to start reading back from.

argument (first)

The key values to read. These are also known as high-order values.

This command option is compulsory if no start values are specified.

The total number of high-order and start values must be the same as the number of profile keys.

FROM

Reads records in profile order.

BACK

Reads records in reverse profile order.

arguments (second)

The key values to start reading from, if the From command option is specified. Otherwise, the key values to start reading back from, if the Back command option is specified. These are also known as start values.

This command option is compulsory if no high-order values are specified.

The total number of high-order and start values must be the same as the number of profile keys.

UNTIL argument

The terminating key values. These are also known as end values.

This command option is only valid if start values are specified.

The number of end values must be the same as the number of start values.

SERIAL

Increases efficiency by retaining pointers.

SECURE

Facilitates record locking of the database in an applications that do not force integrity.

KEYONLY

This command option is not supported on applications deployed to Windows.

MULTI records

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records retrieved, using the specified qualifier.

Determine Last

Reads a single persistent class record that matches specified key values into memory from the database. If there is no match, the preceding record is read instead.

DETERMINE LAST <iterator> [ SECURE | KEYONLY ] [ GS status ]
<iterator> := <object> | <profile>
<object> := object_name ( argument [ ,...n ] )
<profile> := object_name.profile_name( argument [ ,...n ] )
Option Description

iterator

The profile or persistent class to read. If a class is specified, records are read using the class's default profile.

,…n

The key values to start reading back from.

SECURE

Facilitates record locking of the database in an applications that do not force integrity.

KEYONLY

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records in the set, using the specified qualifier.

Determine Total

Reads persistent class records that match the specified key values into memory from the database and totals the specified record attribute in Glb.Total.

DETERMINE LAST <object> attribute_name MULTI records [ GS status ]
   <logic_block>
END

<object> := object_name ( argument [ ,...n ] )
Option Description

object

The profile or persistent class to read. If a class is specified, records are read using the class's default profile.

,…n

The key values to start reading back from.

attribute_name

The record attribute to total.

MULTI records

This command option is not supported on applications deployed to Windows.

GS status

Indicates if there are no records in the set, using the specified qualifier.

Divide

Divides the value of a numeric expression by the value of a number-primitive variable, and stores the result in that variable, or optionally in a specified result variable.

DIVIDE expression variable [ GIVING variable ] [ ROUNDED ] [ REMAINDER variable ]
[ GS status ]
OptionDescription

expression variable

The number expression to divide the qualifier by. The qualifier also receives the result if the Giving command option is not specified. If the Giving option is specified then qualifier might be replaced by an expression.

(GIVING or GIV) variable

Directs the result to the specified qualifier.

(ROUNDED or ROU)

Rounds the result when truncation occurs.

(REMAINDER or REM) variable

Directs the true remainder of the division to the specified remainder number-primitive variable.

GS status

Indicates division by zero or arithmetic overflow using the specified variable.

If/DoWhen

Introduces a sequence of logic statements to execute if a specified conditional expression is evaluated as true. This sequence of logic statements is terminated by an Arrays, End, EndExit, or EndNoPrint logic statement following the DoWhen logic statement. If is the preferred usage of the DoWhen logic command. Refer to IF logic command for more information on this command.

DO { expression | tclass_attribute [NOT] NUMERIC }
   <logic_block>
[ WHEN 
   <logic_block> ]  
END | ENDEXIT | ENDNOPRINT 
Option Description

expression

The conditional expression to evaluate.

class_attribute

When used with the NUMERIC keyword, DoWhen should only be used with an attribute name.