100% found this document useful (3 votes)
3K views41 pages

CoolGen - Syntax

The document summarizes the main statement types in Cool:Gen syntax, including: 1) Sequential statements like SET, MOVE, and NOTE for assigning values, moving entity views, and adding comments. 2) Conditional statements like IF/ELSEIF/ELSE and CASE OF for specifying conditional actions. 3) Repeated statements like FOR, FOR EACH, and WHILE for repeating actions based on conditions or iterations. 4) Control statements like ESCAPE, EXIT STATE IS, and USE for terminating execution, setting exit states, and referencing common logic. 5) Entity occurrence statements like CREATE, READ, and READ EACH for storing, retrieving, and iterating over entity

Uploaded by

api-19975532
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
3K views41 pages

CoolGen - Syntax

The document summarizes the main statement types in Cool:Gen syntax, including: 1) Sequential statements like SET, MOVE, and NOTE for assigning values, moving entity views, and adding comments. 2) Conditional statements like IF/ELSEIF/ELSE and CASE OF for specifying conditional actions. 3) Repeated statements like FOR, FOR EACH, and WHILE for repeating actions based on conditions or iterations. 4) Control statements like ESCAPE, EXIT STATE IS, and USE for terminating execution, setting exit states, and referencing common logic. 5) Entity occurrence statements like CREATE, READ, and READ EACH for storing, retrieving, and iterating over entity

Uploaded by

api-19975532
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 41

COOL:Gen Syntax

• The statements in Cool:Gen can be broadly divided into the


following categories:

• Sequential Actions
• Conditional Actions
• Repeated Actions
• Control Actions
• Entity Occurrence Actions
• Pairing Actions

atyam Computer Services Limited 1


Sequential Actions

SET Statement

SET is an assignment action used to assign values to attribute


views.

The format of SET action statement is:

SET view-1 attribute-view-1 [ROUNDED] TO expression


[SUBSCRIPT] [NOT ROUNDED]
[LAST of group-view]

atyam Computer Services Limited 2


Sequential Actions

MOVE Statement

MOVE assigns the values of all attribute views for an entity


views at once. A MOVE is not required for each attribute value
in the view.

The format of MOVE action statement is:

MOVE view-1 TO view-2

view-1 and view-2 should be of the same entity type/work view.

atyam Computer Services Limited 3


Sequential Actions

NOTE Statement

Note allows you to add your own annotations and comments


anywhere in the action diagram.

atyam Computer Services Limited 4


Conditional Actions

IF/ELSEIF/ELSE Statement

IF specifies the condition under which process actions take


place.
Simple mutually exclusive conditions can be added to the IF
condition.
+-> IF condition-1 (AND/OR condition-2)
| process statements....
| ..........
+-ELSEIF
| process statements....
| ..........
+-ELSE
| process statements....
+--
atyam Computer Services Limited 5
Conditional Actions

CASE OF/CASE Statement

CASE OF conditional action specifies actions that depend on the


value of one of the items listed in the CASE statements.

+->CASE OF expression-1
+->CASE constant-1
| process statements....
+->CASE constant-1
| process statements....
+->OTHERWISE
| process statements....
+--

atyam Computer Services Limited 6


Repeated Actions

FOR Statement

The FOR conditions causes an action or group of actions to be


repeated according to the criteria you specify for a local numeric
attribute view or an explicitly indexed repeating group view.

Format 1
+->FOR local-view-1 FROM num-1 TO num-2 BY num-3
| process statements....
+--

Format 2
+->FOR SUBSCRIPT OF group-view-1 FROM num-1 TO
| LAST OF group-view-1
| process statements....
+--
atyam Computer Services Limited 7
Repeated Actions

FOR EACH Statement

The FOR EACH repeating action repeats the action group for each
occurrence of an implicitly indexed repeating group view

+->FOR EACH group-view-1


| TARGETING group-view-2 FROM THE BEGINNING
| UNTIL FULL
| process statements....
+--

TARGETING clause allows you to identify the repeating export or local


group view to be populated.

atyam Computer Services Limited 8


Repeated Actions

WHILE Statement

Repeats an action or group of actions as long as the condition is


true.

+->WHILE condition-1
| TARGETING group-view-2 FROM THE BEGINNING
| UNTIL FULL
| process statements....
+--

Can contain more than one TARGETING statements.

The test for the condition takes place first. If the condition is not met then
there are no iterations.
atyam Computer Services Limited 9
Control Actions

ESCAPE Statement

ESCAPE terminates the execution of a particular action group.


Mostly used after exception conditions, such as ROW already exists in
the table or ROW not found in the table.

+-> IF condition-1
| +-> IF condition-2
| | +-> IF condition-3
| | | +-> IF condition-4
| <--------- ESCAPE
| | | +--
| | +--
| +--
| process statements......
+--
atyam Computer Services Limited 10
Control Actions

EXIT STATE IS Statement

EXIT STATE IS sets the value of the special attribute, exit state.

EXIT STATE IS exit-state-value

• Can hold only one value at a time.

•An ESCAPE statement usually follows the EXIT STATE statement.

• An EXIT STATE causes the transfer of control from one procedure


step to another. A dialog flow takes place on the existence of one or
more exit states.

atyam Computer Services Limited 11


Control Actions

EXIT STATE IS Statement - Example

EXIT STATE IS customer_not_found

atyam Computer Services Limited 12


Control Actions

USE Statement

USE statement references the logic in common action blocks.

The logic is common in that it can also be used in other processes,


procedures, and action blocks(including external action blocks).

Format
process statements....

USE action-block-1
WHICH IMPORTS:import-1,import-2...
WHICH EXPORTS:export-1,export-2...

process statements....

atyam Computer Services Limited 13


Control Actions

USE Statement

• Match the views (of called and calling action block).


• Matching is possible only between similar(entity/work) views.

• After execution, the control returns to the statement after the USE
statement.

atyam Computer Services Limited 14


Entity Occurrence Actions

CREATE Statement

• Stores information about entities.

• Entity should be defined in the entity action view of the action diagram.

• SET statement to assign value to the attributed.

• If any attribute is not assigned value using SET statement then the
attribute takes the default value defined.

• ASSOCIATE statement used to set the associations.

atyam Computer Services Limited 15


Entity Occurrence Actions

CREATE Statement

Format

+-> CREATE entity-view-1


| [SET attribute-view-1 TO expression ]
| [ASSOCIATE WITH entity-view-2 WHICH
| relationship IT]
+-> WHEN SUCCESSFUL
| processing statements...
+-> WHEN ALREADY EXISTS
| processing statements...
+-> WHEN permitted value violation
| processing statements...
+--

atyam Computer Services Limited 16


Entity Occurrence Actions

READ Statement

• Retrieves a single occurrence of one or more entity types based on the


selection criteria specified.

• Format

+-> READ entity-view-1(,entity-view-2...)


| [WHERE selection-condition]
+-> WHEN SUCCESSFUL
| processing statements...
+-> WHEN NOT FOUND
| processing statements...
+--

atyam Computer Services Limited 17


Entity Occurrence Actions

READ Statement

• Example - 1

+-> READ loan


| WHERE DESIRED loan num = import loan num
| ........
+--

• Example - 2

+-> READ loan_transaction


| WHERE DESIRED loan_transaction
| is_contained_by CURRENT loan
| ........
+--
atyam Computer Services Limited 18
Entity Occurrence Actions

READ Statement

• Example - 3

+-> READ loan_transaction


| WHERE DESIRED loan_transaction contains SOME
| loan
| AND THAT loan num = import loan num
| ........
+--

atyam Computer Services Limited 19


Entity Occurrence Actions

READ EACH Statement

• Retrieves multiple occurrence of one or more entity types based on the


selection criteria specified.
• One iteration occurs for each entity occurrence satisfying the selection
criteria specified.

• Format

+-> READ EACH entity-view-1(,entity-view-2...)


| [TARGETING group-view-1 FROM THE BEGINNING
| UNTIL FULL]
| [WHERE selection-condition]
| processing statements...
+--

atyam Computer Services Limited 20


Entity Occurrence Actions

READ EACH Statement

• Example

+-> READ EACH loan_transaction


| TARGETING export_group FROM THE BEGINNING
| UNTIL FULL
| WHERE DESIRED loan_transaction contains
| CURRENT loan
| ........
+--

• For each iteration, the subscript of the group view will be incremented
by 1.

atyam Computer Services Limited 21


Entity Occurrence Actions

READ EACH Statement - Options

• Distinct
• Always generate cursor with Distinct.
• Never generate cursor with Distinct.
• Use default.

• Select clause isolation level


• Repeatable
• Cursor Stable
• Uncommitted/Browse
• Default

atyam Computer Services Limited 22


Entity Occurrence Actions

READ EACH Statement - Options

• Optimize for N rows.


• Do not generate optimize clause
• Use TARGETING value, when present
• Use the value - 9999.

atyam Computer Services Limited 23


Entity Occurrence Actions

UPDATE Statement

• Can change the attribute value of an entity occurrence.

• Can update the relationships.

• Should be preceded by a READ/CREATE statement to identify the row


to be updated.

atyam Computer Services Limited 24


Entity Occurrence Actions

UPDATE Statement

Example

+-> UPDATE entity-action-1


| SET attribute-1 TO [VALUE]
| SET attribute-2 TO [VALUE]
| .........
| ASSOCIATE WITH entity-view-1 WHICH
! relationship-1
+-> WHEN SUCCESSFUL
| processing statements...
+-> WHEN NOT FOUND
+--

atyam Computer Services Limited 25


Entity Occurrence Actions

DELETE Statement

• Removes an occurrence of an entity.


• Should be preceded by a CREATE/READ statement to identify the row
to be deleted.
• Cascade deletion. (Cool:GEN level or Database level).

Format
+-> READ entity-view-1
| WHERE [condition-1]
+-> WHEN successful
| DELETE entity-view-1
+-> WHEN not found
| processing statements...
+--

atyam Computer Services Limited 26


Entity Occurrence Actions

DELETE Statement

• Example

+-> READ loan


| WHERE DESIRED loan loan_num = import loan
| loan_num
+-> WHEN SUCCESSFUL
| DELETE loan
+-> WHEN NOT FOUND
| processing statements...
+--

atyam Computer Services Limited 27


Pairing Actions

ASSOCIATE Statement

• Breaks a specific pairing along a specific relationship.


• ASSOCIATE has to be used for mandatory relationships.
• ASSOCIATE may be used for optional relationships.
• Used with CREATE or UPDATE statement or as standalone statement.

• Format 1 - with CREATE/UPDATE

ASSOCIATE WITH entity-view-1 WHICH relation-1 IT

• Format 2 - as stand alone statement

ASSOCIATE entity-view-1
WITH entity-view-2 WHICH relation-1 IT

atyam Computer Services Limited 28


Pairing Actions

ASSOCIATE Statement

• Example 1

+-> CREATE loan_transaction


| SET loan_transaction effective_date TO
| 20020101
| SET loan_transaction updated_date TO ‘SATYAM’
| ASSOCIATE WITH loan WHICH identifies IT
+--
• Example 2

+->ASSOCIATE loan_transaction
| WITH loan WHICH identifies IT
+--

atyam Computer Services Limited 29


Pairing Actions

DISASSOCIATE Statement

• Establishes a pairing along a relationship between two entities.


• DISASSOCIATE can be used only for optional relationships.
• Used with UPDATE statement.

• Format 1 - With Update statement

DISASSOCIATE FROM entity-view-1 WHICH relation-1


IT

• Format 2 - With Update statement

DISASSOCIATE entity-view-1
FROM entity-view-2 WHICH relation-1 IT

atyam Computer Services Limited 30


Pairing Actions

DISASSOCIATE Statement

• Example 1

+-> UPDATE loan_transaction


| SET loan_transaction effective_date TO
| 20020101
| SET loan_transaction updated_date TO ‘SATYAM’
| DISASSOCIATE FROM loan WHICH identifies IT
+--
• Example 2

+->DISASSOCIATE loan_transaction
| FROM loan WHICH identifies IT
+--

atyam Computer Services Limited 31


Pairing Actions

TRANSFER Statement

• Transfers the relationship between specific entity occurrences.


• TRANSFER can be used only for relationships defined as transferable.
• Used with CREATE/UPDATE statement or stand alone statement.

• Format 1 - With Create/Update statement

TRANSFER entity-view-1 WHICH relation-1 IT


TO entity-view-2 WHICH relation-2 IT

• Format 2 - stand alone statement

TRANSFER FROM entity-view-1 WHICH relation-1 IT


TO entity-view-2 WHICH relation-2 IT

atyam Computer Services Limited 32


Miscellaneous Actions

SUMMARIZE Statement

• Allows the aggregate functions COUNT, MAX, MIN, AVERAGE and


SUM to be used.

• Similar to READ except that one or more PLACING clauses are


required.

• PLACING clause assigns the value retrieved by the aggregate function


to modifiable fields.

• One or more PLACING clauses can be used for a single SUMMARIZE.

• Can contain a WHERE clause to add the selection criteria.

atyam Computer Services Limited 33


Miscellaneous Actions

SUMMARIZE Statement

• Format

+-> SUMMARIZE entity-view-1, entity-view-2,...


| PLACING aggregate function-1 INTO attribute-1
| PLACING aggregate function-2 INTO attribute-2
| PLACING...
+--

• Example

+-> SUMMARIZE loan


| PLACING count(OCCURENCES) INTO local
| ief_supplied count
+--
atyam Computer Services Limited 34
Miscellaneous Actions

SUMMARIZE EACH GROUP Statement

• Allows the aggregate functions COUNT, MAX, MIN, AVERAGE and


SUM to be used.

• Divides into subgroups based on common attribute values.

• Similar to GROUP BY clause in SQL.

• WITH THE SAME clause used with SUMMARIZE EACH to designate


the common attributes

• TARGETING clause can be used with SUMMARIZE EACH.

• Can contain a WHERE clause to add the selection criteria.

atyam Computer Services Limited 35


Miscellaneous Actions

SUMMARIZE EACH GROUP Statement

• Format

+-> SUMMARIZE EACH GROUP OF entity-view-1


| WITH THE SAME entity-view-1 attribute-1
| TARGETING group-view-1 FROM THE BEGINNING
| UNTIL FULL
| PLACING aggregate function-1 INTO attribute-2
| WHERE [selection condition]
| processing statements....
+--

atyam Computer Services Limited 36


Miscellaneous Actions

SUMMARIZE EACH GROUP Statement

• Example

+-> SUMMARIZE EACH GROUP OF product


| WITH THE SAME product id
| PLACING product id INTO local product id
| PLACING GROUP sum(order_line qty_ordered *
| product unit_price) INTO local ief_supplied
| currency
| WHERE DESIRED product is_ordered_in CURRENT
| order_line
| processing statements....
+--

atyam Computer Services Limited 37


Miscellaneous Actions

MAKE Statement

• Sets the video properties of screen fields from an action diagram.

• Can be used only in online procedures.

• Is active only in procedure step, will not be active in action diagrams.

• Example

MAKE export customer name Unprotected High


Intensity Containing Cursor

atyam Computer Services Limited 38


Miscellaneous Actions

COMMAND IS Statement

• Sets the value of the special attribute, command.

• Can hold only one value at a time.

• Used mainly to control flow within the procedure step.

• Format

COMMAND IS command_value

• Example

COMMAND IS ADD

atyam Computer Services Limited 39


Interface

Screen Design

• Visual Layout of the views imported to and exported from the


procedure step.

• Screen can contain the following components.

• Fields.

• Literals.

• Prompts.

• Special Fields

atyam Computer Services Limited 40


atyam Computer Services Limited 41

You might also like