% (Wildcard)

Used with the LIKE operator to construct patterns for matching.

Comments

Used with the LIKE operator in logic expressions, the % wildcard matches zero or any number of subsequent characters when the pattern on the right is compared to expression1.

Example

"_ ob%"

Matches any character string whose second and third letters are ob, followed by zero or more characters (i.e., “Robert”, “Bob”, “Cobbler”, etc.).

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.

Grade like "100\%"

Shows the percent sign being used literally in a string. (The first backslash “escapes” the second backslash, which, in turn, “escapes” the percent sign, turning it into a literal character.)

find Parts where PartDesc like "%\\%"

Finds parts whose part description contains a backslash.

FirstName like $ concat(" S_e%p", SuffixVariable)

Assuming that SuffixVariable is “%”, then the above expression is logically true if FirstName matches the pattern “S_e%p%”.

The LIKE Operator, The %Wildcard and SQL Servers

The LIKE Operator with %Wildcard sometimes operate differently in SQL servers than in ZIM. The following construction:

find Parts where PartDesc like "%e"

in some SQL servers might only retrieve records when the PartDesc ends exactly with an “e” in the last position of the field. If PartDesc is 5 characters long, the “rode” and “are” will not be retrieved, whereas “there” and “force” will be.

To solve this situation, the above construction must be written this way:

find Parts where $trim(PartDesc) like "%e"

See Also

Conventions

How To Construct Logic Expressions

How To Use Logic Expressions

$mask

Applies a mask pattern to the specified data item.

For a more detailed explanation of mask patterns and their relation to data types, see Masking.

Syntax

$mask(item,pattern)

Parameters

item
  • A value of any type or an expression that yields a value of any type; or
  • An field of any data type.
pattern
  • The mask pattern to apply to item.
  • alphanumeric;
  • a constant, a variable, a parameter, or a field.

Return Value

Character string, containing the masked value.

Comments

  • Mask patterns consist of special characters and fixed text characters;
  • Fixed text characters are always output as is;
  • The set of special characters available for use to mask a particular data value is determined by the data type of value being masked (character string, date, or number );
  • Most special characters are typically replaced by characters from item, but they can also output characters in their own right (e.g., the floating currency symbol: $, which can be customized);
  • The Language Customizer utility (ZIMLANG) can be used to redefine how certain special characters are displayed or output.
    For example, in numeric masks, the currency symbol $ normally outputs a dollar sign, but it can be configured to output other symbols, such as the pound sign £ or yen sign ¥.

Examples

list all Employees format FirstName LastName
($mask(DeptNum,”?epartment Number ??”))

Displays values of DeptNum, such as “D09”, as “Department Number 09”, instead of “D09”.

list all Employees format FirstName LastName
($mask(Salary,”$$$$$$9.99″))

Displays all values of Salary with a floating dollar sign.

$mask ($date, “MM-DD-YY”)

Evaluates to “08-18-98” if $Date is 19980818.

$tocharacter

Converts an expression to the character data type and sets the length of the result.

Syntax

$tocharacter(expression,length)

Parameters

expressionAny value, or an expression that yields any value.
lengthA number that specifies the number of characters in the resulting character string. Length can be a constant, a variable, a form field, or a parameter.

Return Value

Character (char), length bytes long.

Comments

Use $tocharacter to convert expression to the CHAR data type in an area length bytes long. If length is negative, the result string is set to the maximum possible length.

String comparisons involving this function are case-sensitive.

If expression is a number, the number is converted to character string form in an area length bytes long. If the given area is not large enough to hold the converted value, an error results.

Example

Assume LastName is “Smith “.

$tocharacter(LastName,3)

Evaluates to “Smi”.

$tocharacter(LastName,12)

Evaluates to “Smith “.

$tocharacter(50,2)

Evaluates to “50”.

$tocharacter(200+300,20)

Evaluates to ” 500″ (17 leading spaces).

$tocharacter(500,-2)

Evaluates to ” 500″ (14 leading spaces).

list all Emps format $tocharacter(FirstName,6), $tocharacter(LastName,9)

$tocharacter changes the width of values being output with a LIST command.

XOR

Performs a Boolean XOR of two logic expressions.

Syntax

expression1 XOR expression2

Parameters

expression1Any conditional expression or Boolean expression. If the expression is complex, it must be enclosed in parentheses.
expression2Any conditional expression or Boolean expression. If the expression is complex, it must be enclosed in parentheses.

Return Value

Logical as follows:

Truth Table for Boolean XORExpression 1
TrueFalse
Expression 2TrueFalseTrue
FalseTrueFalse

Comments

Performs a Boolean XOR (exclusive OR) of two logic expressions.

Example

LastName = “Smith” xor FirstName = “John”

The entire expression is logically true only if LastName is Smith or FirstName is John, but not both; otherwise, the entire expression is logically false.

See Also

About Boolean Expressions

About Conditional Expressions

OR

$position

Locates the first occurrence of a pattern in a character string.

Syntax

$position(source,pattern)

Parameters

sourcea character string, or an expression that evaluates to a character string
patterna character string, or an expression that evaluates to a character string

Return Value

Number, being the position of the first character in source that matches the first character of pattern, when pattern is found in source.

Comments

$position returns a number that identifies the start position of pattern in source. If pattern is not found in source, $position returns 0.

If either source or pattern is not of a character data type, it is converted to a character string before the operation begins. If source is of data type ALPHA or VARALPHA, the operation is case-insensitive; otherwise, the operation is case-sensitive.

Example

$position(var1,"ab")

Evaluates to 4 if var1 is “defabc”.

$position("abcdef","zz")

Evaluates to 0.

find all Customers where $position(Comments, "overdrawn") > 0

Determines if the word overdrawn appears in the Comments field for any one of your Customers.

See Also

$concat

$delete

$insert

$left

$replace

$right

$substring

$translate

About Character Literals

About Functional Expressions

$insert

Inserts a character string into another character string.

Syntax

$insert(source,position,string)

Parameters

sourcea character string, or expression that evaluates to a character string
positiona number or an expression that evaluates to a number
stringa character string, or expression that evaluates to a character string

Return Value

Character string consisting of source, with string embedded starting at the specified position.

Comments

Use $insert to produce a string consisting of source, with string embedded starting at position.

In a string, the position of the first character is always 1. If position is beyond the end of source, then string is appended to source. If position is zero or negative, then source is left unchanged.

Example

$insert("12345",3,"abc")

Evaluates to “12abc345”.

$insert("abc",1,"de")

Evaluates to “deabc”.

$insert("abc",4,"def")

Evaluates to “abcdef”.

$insert($delete("abcdef,2,2),2,"123")

Evaluates to “a123def”.

See Also

$delete

$fill

$left

$position

$replace

$right

$squeeze

$substring

$translate

$toalpha

Converts an expression to the alpha data type and sets the length of the result.

Syntax

$toalpha(expression,length)

Parameters

expressionAny value, or an expression that yields any value.
lengthA number. Can be a constant, a variable, a parameter, a menu item, or a form field.

Return Value

Character string (alpha), length bytes long.

Comments

Use $toalpha to convert expression to the alpha data type in an area length bytes long. If length is negative, the result string is set to the maximum possible length. If length is zero, the result is the null string.

String comparisons involving this function are case-insensitive.

If expression is a number, the number is converted to character string form in an area length bytes long. If the given area is not large enough to hold the converted value, an error results.

Example

Assume that LastName is “Smith “.

$toalpha(LastName,3)

Evaluates to “Smi”.

$toalpha(LastName,12)

Evaluates to “Smith “.

$toalpha(50,2)

Evaluates to “50”.

$toalpha(20+30,19)

Evaluates to ” 50″ (17 leading spaces).

$toalpha(200+300,20)

Evaluates to ” 500″ (17 leading spaces).

$toalpha(500,-2)

Evaluates to ” 500″ (14 leading spaces).

list all Emps format $toalpha(FirstName,6), $toalpha(LastName,9)

Alters the width of values being output with a LIST command.

See Also

$left

$substring

$tochr

$tonumber

$toord

About Character Literals

About Functional Expressions

Conversion Between Data Types

$delete

Deletes a portion of a character string.

Syntax

$delete(source,position,length)

Parameters

sourcea character string or an expression that evaluates to a character string
positiona number or an expression that evaluates to a number
lengtha number or an expression that evaluates to a number

Return Value

Character string, consisting of source, less those characters starting at position, for a length of length.

Comments

In a string, the position of the first character is always 1. If position is beyond the end of source, or if position is zero or negative, then no characters are deleted from source.

If length is zero or negative, then no characters are deleted from source.

If there are fewer than length characters from position to the end of source, then all characters from position to the end of source are deleted.

Example

$delete("abcdef",2,2)

Evaluates to “adef”.

$delete("613-555-1234",1,4)

Evaluates to “555-1234”.

See Also

$concat

$fill

$insert

$left

$position

$replace

$right

$squeeze

$substring

About Character Literals

About Data Types

About Functional Expressions

LOCATE

Locates a particular member of a result set and makes it the current member.

Syntax

LOCATE [num] [set] [WHERE clause]

Parameters

numThe number of records to be located. Num can be
an integer constant (e.g., 15, 200);
a variable, form field, menu item, or formal parameter that evaluates to an integer;
the word ALL.
The default value for num is 1.
setThe name of a result set. If not specified, the current set (if it exists) is used.

Comments

LOCATE starts searching at the current member of the set. The last member located becomes the current member of set. The system variable $Located is set to the number of members located, indicating the number of members in the result set.

The WHERE clause can be used to logically limit the members located.

Example

find all employees where location=”Detroit” -> DetroitSet

locate DetroitSet where FirstName=”John” and LastName=”Smith”

locate 2 DetroitSet where FirstName=”John” and LastName=”Smith”

Because LOCATE starts with the current member of any set it searches, the current member after the last LOCATE command is the third record containing the name John Smith.

find all Employees where LastName=”Smith” -> Smiths

locate all where FirstName=”John”

output $located

compute all Employees where LastName=”Smith” and FirstName=”John” valuate (“”)

output $membercount

find all Employees where LastName=”Smith” and FirstName=”John”

output $setcount

All three of the preceding examples determine how many employees have the name John Smith.

while

locate DetroitSet where LastName=”Smith” and FirstName=”John”

if $located = 0

  return    % checks if done

endif

ProcessEmp ( )  % program to process this John Smith

endwhile

Each John Smith record in the designated set is processed.

See Also

BOTTOM

DOWN

NEXT

PREVIOUS

TOP

UP

UPDATE

Changes data in EntitySets, relationships, forms, or sets.

Syntax

UPDATE [ALL] [SQLsetspec] SET «field = value »
[WHERE clause [EVALUATE clause] [-> clause]

Parameters

ALLOptional. Regardless of whether ALL is entered, all records in the set specification that meet the specified condition (if any) are updated.
SQLsetspecAn SQL set specification. Can contain application documents, EntitySets, relationships, forms, and sets. Role names are permitted.
If SQLsetspec is omitted, the current set is used (if it exists). Application documents named in the SQLsetspec may not be updated.
fieldA target field in SQLsetspec.
valueCan be:
Any value expression.
The keyword NULL.
Field is assigned either the value of the expression, or the $Null property, as specified.
Any number of field = value assignments may be entered. If a field is not explicitly specified for update, its value remains unchanged.

Comments

The function of the UPDATE command is similar to that of the CHANGE command. UPDATE is able to update more than one database file in one command.

Example

update Employees set Salary = Salary * 1.1

change all Employees let Salary = Salary * 1.1

The preceding two commands are equivalent. Notice that, although the ALL has been omitted from the UPDATE command, it nevertheless updates all records that conform to the set specification.

update Employees, Departments
set Employees.Salary = Departments.StdSalary
where Employees.DNo = Departments.DNo

In the preceding command, the join condition appears in the WHERE clause. Notice that no relationship is needed.

See Also

ADD

CHANGE

Conventions

en_CAEnglish