SET OUTPUT FORMAT

Establishes the format for data output.

Syntax

SET OUTPUT FORMAT [ NORMAL  |  COMMADELIMITED  |  XML  |  XMLSIMPLE  |  JSON  |  JSONSIMPLE ]

Comments

The value of OUTPUT FORMAT is NORMAL by default. That is, the LIST and OUTPUT commands create output whose format exactly follows the Object Dictionary definitions of the individual fields being output. The SET OUTPUT FORMAT command can be reset to enable these commands to output data in comma-delimited format, XML, or XMLSIMPLE formats.

When using the comma-delimited format, database fields are separated from one another by the current delimiter character. This is normally a comma but can be changed using the SET DELIMITER command. Character-type fields have trailing blanks removed and are enclosed within a pair of text delimiters. This is normally double quotation marks but can be changed using the SET TEXTDELIMITER command. Numeric fields have leading blanks removed.

When using the XML format, database fields are printed using XML conventions. Each XML “record” describes all fields in full detail of the actual record being printed. In other words, each row being printed has sub-rows displaying each field of the row. In turn, each sub-row displays the content of each field.

When using the XMLSIMPLE format, database fields are printed using XML conventions in a simple format. Each XML “record” only describes the field names and their corresponding values.

Fields that are $Null are output using the current SET NULLVALUE string (without text delimiters). If NULLVALUE is a space character, fields that are $Null are output as a pair of text delimiters.

The formats JSON and JSONSIMPLE produce a JSON-structured output. JSONSIMPLE compresses all blanks whereas JSON outputs in a formatted way.

Remarks

The XML,  XMLSIMPLE, JSON, and JSONSIMPLE format options are only designed for output.

A header can be attached to the output document by using the command SET XMLHEADER.

The identification of each row being printed can be changed by means of the command SET XML ROWELEMENT.

Example

set save
set heading off
set nullvalue "$null"
set output fieldlistwidth off
set output maskfield off
set output virtualfield off
set output format commadelimited
set output UnstructuredDoc
list all Customers
set restore
set output maskfield on    % not saved by save/restore
set save
set output format xmlsimple
set xml rowelement "MyRow"
set output MyDoc
list 1 Doc
set restore

See Also

LIST

OUTPUT

SET DECIMALS

Enables or disables the requirement of typing the decimal point.

Syntax

SET DECIMALPOINT ON|OFF

Comments

The DECIMALPOINT option is set ON by default.

DECIMALPOINT only has an effect on entry fields during FORM INPUT:

When DECIMALPOINT is ON:

typed digits fill the input mask from the right-most digit leftwards

there is no need to type the decimal point since its presence is assumed

mimics the functionality of TUI for numeric values with decimal point

When DECIMALPOINT is OFF:

typed digits fill the input mask from the first digit to the left of the decimal point leftwards

typed digits are assumed to belong to the integer part of the numeric value

decimals are assumed to be 0.

if there are decimals in the input numeric value, the decimal point must be typed

Example

set decimalpoint on

set decimalpoint off

Examples: Numeric value of an Entry Field with input mask =”9999.99” after a FORM INPUT.

Keys PressedONOFF
1001.00100.00
12345123.4512345.00
123.45123.45123.45
.999999

See Also

SET ERRORS

SET SELECTIVITY

Specifies index selectivity for indexed fields.

Syntax

SET SELECTIVITY fieldname value1 value2 value3

or

SET < fieldname> SELECTIVITY value1 value2 value3

Parameters

fieldnameThe name of an indexed field.
value1A number in the range 0.000 to 1.000. The number specifies the index selectivity for equality (=) searches.
A number above or below the acceptable range result in an error. A value1 of 1.000 instructs the software to use an internal default value for selectivity.
value2A number in the range 0.000 to 1.000. The number specifies the index selectivity for [NOT] BETWEEN searches.
A number above or below the acceptable range results in an error. A value2 of 1.000 instructs the software to use an internal default value for selectivity.
value3A number in the range 0.000 to 1.000. The number specifies the index selectivity for other searches (<, >, <=, >=).
A number above or below the acceptable range results in an error. A value3 of 1.000 instructs the software to use an internal default value for selectivity.

Comments

Index selectivity represents the fraction of records that you would expect to retrieve with a particular kind of search. For example, for an indexed field called Gender, you can expect an equality search to have a selectivity ratio (value1) of 0.500 (about half the records contain “male”; the other half, “female”). The strategy analyzer uses the values you supply to determine the best use of indexed fields in a retrieval operation.
The SET SELECTIVITY option has no effect on the Fields EntitySet in the Object Dictionary.
The SET SELECTIVITY option is not affected by the SET RESET and SET RESTORE commands.

Example

set selectivity Emps.Gender 0.5 0.5 0.5

set selectivity Emps.Age 0.02 0.1 0.5

The preceding commands indicate that Age is a more selective field than Gender. In a command such as find Emps where Age = 39, only about 2 per cent of the records in Emps are expected to be retrieved.

See Also

SET SIZE

SET COMMANDTIMING

Displays how much time each command takes to execute.

Syntax

SET COMMANDTIMING ON|OFF

Comments

The COMMANDTIMING option is set OFF by default.

The SET COMMANDTIMING command controls the output of command timing messages.

In UNIX, the format of command timing messages is

source, line, IU|RU, user ticks, elapsed user ticks, IS|RS, system ticks, elapsed system ticks

source

The name of the application document that contains the command; if it is the ZIM prompt, source is “”.

line

The line number of the line in the application document on which the command begin; if the value of source is “”, the value of line is a sequential number from the prompt.

IU|RU

Can be
IU (interpretive user execution)
RU (runtime user execution)

user ticks

The time it took to interpret the command (for interpretive execution) or the time it took to accept the command for processing (for compiled execution).

elapsed user ticks

The time it took to interpret the command, as seen by the user.

IS|RS

Can be
IS (interpretive user execution)
RS (runtime user execution)

system ticks

The system ticks used by the command. Usually, the system ticks value is lower than the user ticks value.

elapsed system ticks

The number of ticks spent by the execution of the command as seen by the system. Usually the elapsed system ticks value is lower than the elapsed user ticks value.

For Windows systems, the format of command timing messages is

source, line, I|R, user ticks, elapsed user ticks

source

The name of the application document that contains the command; if it is the ZIM prompt, source is “”.

line

The line number of the line in the application document on which the command begin; if the value of source is “”, the value of line is a sequential number from the prompt.

I|R

Can be
I (interpretive user execution)
R (runtime user execution)

user ticks

The time it took to interpret the command (for interpretive execution) or the time it took to accept the command for processing (for compiled execution).

elapsed user ticks

The time it took to interpret the command, as seen by the user.

 

See Also

SET LEXTRACE

SET TRACE

SET TRACEOUTPUT

SET SAVE

Saves the current global application settings in their current state for later use.

Syntax

SET SAVE

Comments

The SET SAVE command records the current state of all global settings, and pushes the group of settings onto a stack of previously saved settings (if any).
The SET RESTORE command pops the top group of settings off the stack, thus restoring the values saved in that group.
The global application settings saved to the stack by SET SAVE include

SET AUTORETRYNOT APPLICABLESET CHECKNULLS
SET COLUMNSPACINGSET CURSORSET DELIMITER
SET DOCLINELENGTHSET EOFVALUESET ERRORS
SET ESCAPECHARSET HEADINGSSET INFORMATION
SET INPUT FORMATSET INPUT TIMEOUTSET MEMBERCOUNT
SET MEMBERINTERVALSET MESSAGESSET MESSAGES WINDOW
SET MOUSESET NULLVALUESET OUTPUT
SET OUTPUT FIELDLISTWIDTHSET OUTPUT FORMATSET OUTPUT MASKFIELD
SET OUTPUT TRIMSET OUTPUT VIRTUALFIELDSET PAGESIZE
SET PAGEWIDTHSET PAUSESET SPECIALSCAN
SET STRATEGYSET TEXTDELIMITERSET TIMEOUT
SET TRACE OUTPUTSET TRANSACTION FLOWSET WARNINGS

The SET SAVE command does not record the state of the following settings:

SET BREAKABLESET CHECKSETSSET CURRENTSET
SET DEPENDENCYSET EXCEPTIONSET FLOW
SET LEXTRACESET QUOTINGSET RUNTIME
SET SELECTIVITYSET SINGLESTEPSET SIZE
SET STOP ERRORSSET TRACESET XREF

Example

set save

set output MyDoc

set headings off

set pause off

set pagewidth 100

set pagesize 100

list all Employees

set restore

In the preceding example, SET SAVE saves the current state of the global settings before OUTPUT, HEADINGS, PAUSE, PAGEWIDTH, and PAGESIZE are adjusted to send data to an application document. SET RESTORE then returns the settings to their previous values.

See Also

SET RESET

SET RESTORE

Restores the top group of settings in the stack of saved global settings created by SET SAVE.

Syntax

SET RESTORE

Comments

The SET SAVE command records the current state of all global settings, and pushes the group of settings onto a stack of previously saved settings (if any).
The SET RESTORE command pops the top group of settings off the stack, thus restoring the values saved in that group.
The global application settings reset to their defaults by SET RESTORE include

SET AUTORETRYNOT APPLICABLESET CHECKNULLS
SET COLUMNSPACINGSET CURSORSET DELIMITER
SET DOCLINELENGTHSET EOFVALUESET ERRORS
SET ESCAPECHARSET HEADINGSSET INFORMATION
SET INPUT FORMATSET INPUT TIMEOUTSET MEMBERCOUNT
SET MEMBERINTERVALSET MESSAGESSET MESSAGES WINDOW
SET MOUSESET NULLVALUESET OUTPUT
SET OUTPUT FIELDLISTWIDTHSET OUTPUT FORMATSET OUTPUT MASKFIELD
SET OUTPUT TRIMSET OUTPUT VIRTUALFIELDSET PAGESIZE
SET PAGEWIDTHSET PAUSESET SPECIALSCAN
SET STRATEGYSET TEXTDELIMITERSET TIMEOUT
SET TRACE OUTPUTSET TRANSACTION FLOWSET WARNINGS

The SET RESTORE command does not record the state of the following settings:

SET BREAKABLESET CHECKSETSSET CURRENTSET
SET DEPENDENCYSET EXCEPTIONSET FLOW
SET LEXTRACESET QUOTINGSET RUNTIME
SET SELECTIVITYSET SINGLESTEPSET SIZE
SET STOP ERRORSSET TRACESET XREF

Example

set save

set output MyDoc

set headings off

set pause off

set pagewidth 100

set pagesize 100

list all Employees

set restore

In the preceding example, SET SAVE saves the current state of the global settings before SET OUTPUT, SET HEADINGS, SET PAUSE, SET PAGEWIDTH, and SET PAGESIZE are adjusted to send data to an application document. SET RESTORE then returns the settings to their previous values.

See Also

SET RESET

SET FOR UPDATE

Instructs SQL commands to be generated with the FOR UPDATE OF option.

Syntax

SET FOR UPDATE ON|OFF

Comments

When connected to any SQL servers, the SQL syntax generated to perform operations on the remote server can be controlled to add the FOR UPDATE OF option on the primary key fields to SELECT commands.

The option ON turns this generation on and remains in effect until another command, this time with the option OFF, is issued. Therefore, all SELECT statements generated by Zim after the switch is turned on will have the FOR UPDATE OF clause until the switch is turned off.

This is useful to guarantee that records will be locked for update within the next SQL commands.

This option setting only applies to SELECT statements generated by Zim in order to perform actions on connected SQL servers.

Example 1

SET FOR UPDATE ON
SET SQLTRACE ON
FIND MyEntA
SELECT FieldA FROM MyEntA FOR UPDATE OF FieldA
FIND MyEntB
SELECT FieldB FROM MyEntB FOR UPDATE OF FieldB
SET FOR UPDATE OFF
FIND MyEntA
SELECT FieldA FROM MyEntA

The FIND statements between the ON and OFF settings will be sent to the connected SQL server with the FOR UPDATE OF clauses.

Example 2

The following Zim program shows a small procedure that takes a control number and then adds a record using this control number as a primary key. The numbers at left are for subsequent reference only.

1  Procedure Prog2() Local (vl_number, vl_1)
2  on deadlock
3          if $intransaction=$true
4                      out $concat(“record blocked – “, $trim(vl_1))
5                      halt
6                      goto trans1
7          else
8                      goto previous
9          endif
10 endon
11
12 trans1:
13 transaction
14 let vl_1=”Compute tblControl”
15 find tblControl -> s1
16 let vl_number=(LastNumber+1)
17 out vl_1
18 out vl_number
19 halt
20 let vl_1=”Add tblCust”
21 add tblcust let custcode = vl_number  
22                     custname = vl_number
23 out vl_1
24 halt
25 let vl_1=”Change tblControl”
26 ch tblControl let LastNumber = vl_number
27 out vl_1
28 halt
29 endtransaction
30
31 EndProcedure

Scenario 1

By default, SET FOR UPDATE is OFF. This is the behaviour found in previous versions of Zim.

If two users are running the same program, then:

. User 1 starts Prog2 and stops at line 19: Vl_number is 1 and no locks were applied by Oracle;

. User 2 starts Prog2 and stops at line 19: Vl_number is 1 and no locks were applied by Oracle;

. User 1 continues execution: a record will be added in TblCust and execution stops at line 24;

. User 2 continues execution: it waits because Oracle serializes the ADD statement in TblCust;

. User 1 continues execution: TblControl is updated, Oracle locks TblControl and execution is halted at line 28;

. User 2 is still waiting…

. User 1 continues execution: Oracle releases the lock in TblControl, the transaction is committed and the program ends;

. User 2 now proceeds: Oracle will try to add a record but a duplicated record error is raised.

Scenario 2

SET FOR UPDATE is set to ON either before calling Prog2 or in line 11 of Prog2:

. User 1 starts Prog2 and stops at line 19: Vl_number is 2 (assuming that a record was added in Scenario 1) and Oracle locks TblControl;

. User 2 starts Prog2, but enters in a waiting state at line 15, since Oracle serializes the SELECT statement (the record is locked);

. User 1 continues execution: the record will be added in TblCust, Oracle locks TblCust and the execution stops at line 24;

. User 2 still waiting…

. User 1 continues execution: TblControl is updated, Oracle locks TblControl and execution stops at line 28;

. User 2 still waiting…

. User 1 continues execution: Oracle releases the lock in TblControl, the transaction is committed and the program ends;

. User 2 resumes execution: Oracle retrieves a TblControl record, Vl_number becomes 3 and the transaction continues normally;

 

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

pt_BRPortuguese