CoolGen - Syntax

41
r Services Limited r Services Limited 1 COOL:Gen Syntax e statements in Cool:Gen can be broadly divided int ollowing categories: equential Actions onditional Actions epeated Actions ontrol Actions ntity Occurrence Actions airing Actions

Transcript of CoolGen - Syntax

Page 1: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 11

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

Page 2: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 22

Sequential Actions

SET Statement

SET is an assignment action used to assign values to attributeviews.

The format of SET action statement is:

SET view-1 attribute-view-1 [ROUNDED] TO expression [SUBSCRIPT] [NOT ROUNDED] [LAST of group-view]

Page 3: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 33

MOVE Statement

MOVE assigns the values of all attribute views for an entityviews at once. A MOVE is not required for each attribute valuein 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.

Sequential Actions

Page 4: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 44

Sequential Actions

NOTE Statement

Note allows you to add your own annotations and commentsanywhere in the action diagram.

Page 5: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 55

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.... +--

Page 6: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 66

Conditional Actions

CASE OF/CASE Statement

CASE OF conditional action specifies actions that depend on thevalue 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.... +--

Page 7: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 77

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 numericattribute 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.... +--

Page 8: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 88

Repeated Actions

FOR EACH Statement

The FOR EACH repeating action repeats the action group for eachoccurrence 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.

Page 9: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 99

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 thenthere are no iterations.

Page 10: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1010

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...... +--

Page 11: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1111

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.

Page 12: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1212

EXIT STATE IS Statement - Example

EXIT STATE IS customer_not_found

Control Actions

Page 13: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1313

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....

Page 14: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1414

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.

Page 15: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1515

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.

Page 16: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1616

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... +--

Entity Occurrence Actions

Page 17: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1717

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... +--

Entity Occurrence Actions

Page 18: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1818

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 | ........ +--

Entity Occurrence Actions

Page 19: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 1919

READ Statement

• Example - 3

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

Entity Occurrence Actions

Page 20: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2020

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... +--

Entity Occurrence Actions

Page 21: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2121

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.

Entity Occurrence Actions

Page 22: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2222

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

Page 23: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2323

READ EACH Statement - Options

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

Entity Occurrence Actions

Page 24: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2424

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.

Page 25: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2525

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 +--

Entity Occurrence Actions

Page 26: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2626

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... +--

Page 27: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2727

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... +--

Page 28: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2828

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

Page 29: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 2929

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 +--

Pairing Actions

Page 30: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3030

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-1FROM entity-view-2 WHICH relation-1 IT

Pairing Actions

Page 31: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3131

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 +--

Pairing Actions

Page 32: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3232

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

Pairing Actions

Page 33: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3333

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.

Page 34: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3434

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+--

Miscellaneous Actions

Page 35: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3535

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.

Miscellaneous Actions

Page 36: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3636

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....+--

Miscellaneous Actions

Page 37: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3737

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....+--

Miscellaneous Actions

Page 38: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3838

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

Page 39: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 3939

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

Page 40: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 4040

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

Page 41: CoolGen - Syntax

Satyam Computer Services Limited Satyam Computer Services Limited 4141