SET (EntitySet/Data Relationship Attribute)

SET (EntitySet/Data Relationship Attribute)

Modifies the value of an attribute of a database object.

Syntax

SET tablename tabletype [ “ZIMSERV” | “JDBCSAM” | alias name ]

SET tablename [ remname |  remowner ] value

SET fieldname [ remname ] value

tablenameis the name of an EntitySet or data relationship
fieldnameis the name of a field in an EntitySet or data relationship
TABLETYPEis the option to modify the location of tablename
REMNAMEis the option to modify the Remote Name of tablename or fieldname
REMOWNERis the option to modify the Remote Owner Name of tablename
alias nameis or as defined in the configuration file “zimalias.zim”.
valueis an expression that evaluates to a string

Comments

These two forms of the SET command modify attributes of EntitySets, data relationships, and fields that affect client-server behavior.

These commands affect the internal value of these attributes. They do not update the external data dictionary. It is prudent to modify the data dictionary to conform to any new attribute values that are set. The utility ZIMFILES can be used to display internal values of any database object.

When modifying TABLETYPE, the value must be a valid SAM name or custom server name. This is equivalent to modifying EntType in EntitySets or RelType in Relationships and then performing “erase” and “create” commands on the EntitySet or data relationship.

Changing the REMNAME or REMOWNER to the value null string (”) removes any Remote Name or Remote Owner Name associated with the database object.

The SET REMOWNER command is equivalent to changing the “RemoteOwner” in “EntitySets” or “Relationships” and then recreating the EntitySet or relationship.

The SET REMNAME command is equivalent to changing the “RemoteName” in “EntitySets” or “Relationships” and then recreating the EntitySet or relationship.

Any compiled Zim programs that reference database objects that have been modified with these commands should be recompiled.

Example 1

To modify the EntitySet Customers so that it is under the control of an Oracle SQL server, enter

> set Customers tabletype 'jdbcsam'
> set MyEnt tabletype 'zimserv'

Example 2

To modify the Remote Name of the field ZIP in EntitySet customers, enter

> set Customers.ZIP remname '"ZIP or Postal Code"'

When modifying the attribute of a field, qualify it with its entity set or relationship name to avoid ambiguity. Note that double quotation marks are included in the REMNAME value. Most database engines require double quotation marks around the column name if it contains embedded blanks.

Example 3

To remove the Remote Name of the field ZIP in EntitySet customers that was added above, enter

> set Customers.ZIP remname ''

See Also

Remote Name Mapping

{ } (Case) – Inline Case Expressions

Unlock the Power of Conditional Logic with Zim Case Expressions

Elevate your Zim application development with our powerful case expressions feature. Designed to streamline your coding process and enhance functionality, case expressions provide a robust solution for handling conditional values effortlessly.

Key Benefits:

  • Efficient Coding: Simplify your code with concise case expressions, reducing complexity and improving readability.
  • Reliable Value Assignment: Ensure non-null values in critical operations, preventing errors and enhancing application stability.
  • Dynamic Adjustments: Implement dynamic logic that adapts to changing conditions, delivering flexible and responsive applications.
  • Graceful Handling of Missing Data: Provide fallback options for missing values, ensuring comprehensive and informative outputs.

Case Expressions in Zim

Syntax:

{ expression1 , expression2 }

Parameters:

  • expression1: Any value expression.
  • expression2: Any value expression.

Return Value:

  • The value of the first expression that is not $Null.

Technical Expansion:

Evaluation Process:

  • Sequential Evaluation: The expressions within the braces are evaluated from left to right. This ensures that the first non-null value is selected, providing a reliable mechanism for conditional value assignment.
  • Nested Expressions: Case expressions can be nested, allowing for complex conditional logic to be handled efficiently. This is particularly useful in scenarios where multiple conditions need to be evaluated in sequence.

Usage Scenarios:

  • Conditional Value Assignment: Case expressions are ideal for assigning values based on conditions. For example, determining a status based on height:
  let Status = {'tall' where Height > 6, 'short'}

This simplifies the code and ensures that the correct status is assigned based on the height condition.

  • Ensuring Non-Null Values: In situations where a field or widget might be $Null, case expressions can provide a default value, ensuring that operations proceed smoothly:
  let Salary = {fAddEmps.Salary, 0}
  • Dynamic Action Determination: Case expressions can be used to determine actions based on conditions, such as adjusting a year based on the month:
  break 1
    {$year(InvDate) + 1 where $month(InvDate) >= 5, $year(InvDate)}
    heading ...
  • Handling Missing Values: In reports or outputs, case expressions can handle missing values gracefully, providing a fallback option:
  detail line "Employee Number: " {EmpNum, "N/A"}

Advanced Features:

  • Platform Independence: Case expressions are versatile and can be used across different platforms, ensuring consistent behavior in various environments.
  • Performance Optimization: By minimizing the code required for conditional logic, case expressions can improve the performance of applications, reducing processing time and resource usage.

Experience the Difference: Transform your Zim applications with the efficiency and reliability of case expressions. Whether you’re streamlining conditional logic, ensuring non-null values, or handling dynamic adjustments, our case expressions feature is your key to superior development.

PARSE

Tests a single Zim command, or an application program, for syntactic and semantic accuracy.

Syntax

PARSE commandstring | docname

Parameters

commandstringAny character string, enclosed in quotation marks, that represents a Zim command to be parsed.
docnameThe name of an application document that contains an application program to be parsed.

Comments

The PARSE command enables you to check an individual command or an entire program without executing either the command or the program. Executing a PARSE command does not affect any data values held either in memory or in the database. The PARSE command reports any syntactic or semantic irregularities that the PARSE command uncovers.

The sets created by FIND commands in parsed programs are defined. Only the directories accessed at the time that the PARSE command is executed are used. The ACCESS and RELEASE commands are parsed but not executed.

A program is parsed on a line-by-line basis. A program called from the program being parsed is not parsed, but the software does check to see if the program exists. All parts of commands with conditions are parsed, regardless of the validity of the conditions or the presence of any BREAK, CONTINUE, or TRANSFORM command.

Example

To check a command before running it, use

parse “list all Employees where LastName = Smith”

If you have an application program MyProg that calls the program SubUserCom, enter

parse MyProg

Only the command statements in MyProg are parsed. The software checks that SubUserCom exists, but does not parse it.

See Also

COMPILE

DEPENDENCY

GENERATE

LET

Assigns a value to a variable object.

Syntax

LET expression

Parameters

targetA global or local variable, a form field or menu item, a parameter, or a macro can be used. Subscripted (array) variables are valid.
expressionAny value expression.
The value of expression is assigned to target. Expression can include literals, constants, global or local variables, form fields, menu items, parameters, or fields in the current set. These objects can be combined using any of the arithmetic operators and functions.

Comments

The LET command is used to assign values to variable objects. To assign values to a field in an EntitySet or relationship, you must use ADD, CHANGE, INSERT, or UPDATE (which can contain a LET subcommand). The LET command is not used to assign values to database fields.

An assignment expression is formed by enclosing the LET command in parentheses.

If expression evaluates to $Null and target is a macro, the macro is assigned the null string. (A null string is a string of zero length, which is not the same as the $Null property.)

Example

let var1[1]=1 var1[2]=2 var1[3]=3

let var1 = $Date var2 = $tolower(LastName) var3[2] = 123

An example of using LET to assign values to variables.

let = “where LastName = Smith”

let= “from terminal prompt”

let <5> = $null

An example of using LET to assign values to macros.

See Also

Macros

ADD

CHANGE

How To Use Variables

INSERT

SET QUOTING

UPDATE

WHERE

COMPUTE

Computes the results of one or more expressions for a set of records.

Syntax

COMPUTE [num] [setspec] EVALUATE clause [-> clause]

Parameters

num

Can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
If num is omitted, or less than 0, it defaults to ALL.

setspec

The set specification (made up of application documents, EntitySets, relationships, forms, or result sets), designating the records to be changed. If omitted, the current set (if available) is used.
Application documents named in the set specification cannot be updated.

Comments

COMPUTE evaluates one or more expressions for a set of records without having to first LIST the data or create a result set of the desired records.

Example

Compute all Employees where LName=Smith \

evaluate \

(let TotSal = $total(Salary)) \

(let MaxSal = $max(Salary)) \

(let MinSal = $min(Salary)) \

(let NoOfEmps = $count(LName)) \

(let AvgSal = $average (Salary))

output TotSal MaxSal MinSal NoOfEmps AvgSal

Processes the EVALUATE clause for every employee whose last name is “Smith”. The OUTPUT command displays the results.

form open dInvoice

form display input

compute fInvItems evaluate (let fInvBott.InvTot = $total(fInvItems.Amt))

form display fInvBott.InvTot

Calls up a display and calculates a total after all items have been added.

 

See Also

$MEMBERCOUNT

FIND

INPUT

Gets serial input from the application user.

Syntax

INPUT «target»

Parameters

targetA list of one or more global or local variables, form fields, menu items, parameters, or macros, in any combination. Subscripted (array) variables are valid. Each item must be separated from the next by a space.

Comments

INPUT provides a simple means of reading a line of input from the application user. The line of input is divided into literal strings based on the delimiter character currently in effect. The literals are assigned to the variables and macros specified in target, in order from left to right.

Example

input TestVar fEmpform.LastName Param1 < CommandName> <3>

When the above command pauses for input, the following constants can be input by the application user:

32 Smith abc LIST abc_def

If current delimiter is the space character, the constants are assigned as follows:

TestVar32
fEmpform.LastNameSmith
Param1abc
#< CommandName>LIST
#<3>abc_def

The following sequence of entries accomplishes the same effect, but uses the comma as the delimiter:

set delimiter “,”

input TestVar fEmpform.LastName Param1 < CommandName> <3>

32,Smith, abc,LIST, abc_def

Attention

When using the following construction, a “:” must be placed at the end of the OUTPUT string:

OUTPUT “Please, respond with Yes or No (Y/N): “;

input vResponse

See Also

SET DELIMITER

OUTPUT

NEXT

Moves the current member pointer one or more members down in a result set.

Syntax

DOWN [num] [setname]

Parameters

numThe number of members farther “down” into setname that the current member pointer is to be moved. Num can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
The default value for num is 1. If num is negative, DOWN num actually moves the current member pointer “up” in the set.
setnameThe name of the result set whose current member pointer you wish to move. If setname is omitted, the current set is used.

Comments

NEXT is a synonym for DOWN.

Example

down 10

Moves the current member pointer 10 members “down” towards the end of the set.

down 5

delete 5

Moves the current member pointer five members “down” and then deletes five members (starting with the new current member).

find Customers -> CustSet

form open fCustomer

form set accelerator F1 F2 Escape

while

 change fCustomer from CustSet

 form display input

 if Event.EventName = “escape”

  break

 else    % use $direction as a handy variable

  let $direction = {-1 where Event.EventName = “F1”, 1}

 endif

 down $direction CustSet

endwhile

Finds a set of customers and then displays the records in the set one at a time.

See Also

$currentmember

BOTTOM

DOWN

LOCATE

PREVIOUS

TOP

UP

ACCESS

Opens an application directory to use the objects contained in it.

Syntax

ACCESS dirname [READ|UPDATE]

Parameters

dirname

Specifies the name of an application directory.

READ

Specifies that you can only read object definitions in dirname, not update object definitions. If neither READ nor UPDATE is specified, READ is the default value.

UPDATE

Specifies that you can read and update object definitions in dirname.

Comments

Initializing an application database (New Database) creates a base application directory called zim. Additional application directories are defined as objects in the application database. To access any directory other than the base application directory, you must issue an ACCESS command for that directory.

Once a directory has been accessed, objects in that directory are available for use. To close a directory (and its objects) to further access, use the RELEASE command.

Use the CREATE, ERASE, RENAME, PERMISSION, ENCRYPT, DECRYPT, COMPILE, UNCOMPILE, SET SIZE, and SET SELECTIVITY commands to change object definitions only in an application directory accessed using the UPDATE option.

By accessing a directory using the READ option, you prevent unwanted modification of the directory contents. Foreign directories can be accessed using READ only.

Example

To access directory ProjectControl in read-only mode, use

access ProjectControl read

or

access ProjectControl

To access the directory Personnel in update mode, use

access Personnel Update

 

See Also

$dirpath

COMPILE

CREATE

DECRYPT

ENCRYPT

ERASE

PERMISSION

RENAME

SET SELECTIVITY

SET SIZE

UNCOMPILE

UPDATE

DOWN

Moves the current member pointer one or more members “down” in a result set.

Syntax

DOWN [num] [setname]

Parameters

numThe number of members farther “down” into setname that the current member pointer is to be moved. Num can be
an integer constant (15, 200);
a variable, form field, or parameter that evaluates to an integer;
the word ALL.
The default value for num is 1. If num is negative, DOWN num actually moves the current member pointer “up” in the set.
setnameThe name of the result set whose current member pointer you wish to move. If setname is omitted, the current set is used.

Comments

NEXT is a synonym for DOWN.

Example

down 10

Moves the current member pointer 10 members “down” towards the end of the set.

down 5

delete 5

Moves the current member pointer five members “down” and then deletes five members (starting with the new current member).

find Customers -> CustSet

form open fCustomer

form set accelerator F1 F2 Escape

while

change fCustomer from CustSet

form display input

if Event.EventName = “escape”

break

else    % use $direction as a handy variable

let $direction = {-1 where Event.EventName = “F1”, 1}

endif

down $direction CustSet

endwhile

Finds a set of customers and then displays the records in the set one at a time.

See Also

$currentmember

BOTTOM

LOCATE

NEXT

PREVIOUS

TOP

UP

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

pt_BRPortuguese