skip to main content

Procedure Division Statements : START

START
General Format
Format 1
START file-name-1 {FIRST}
                  { [ KEY {IS relational-operator {data-name-1      } }] }
                        {IS FIRST                                   }
                        {IS LAST                                    }
                  [ WHILE KEY IS relational-operator {data-name-2} ] 
   [INVALID KEY imperative-statement-1]
     [NOT INVALID KEY inperative-statement-2]
[END-START]
Format 2
START TRANSACTION
Syntax Rules
1.
2.
3.
4.
5.
6.
A.
B.
i.
ii.
iii.
7.
8.
9.
10.
11.
General Rules
Format 1
1.
2.
3.
4.
5.
6.
7.
Relative Files
8.
9.
A.
B.
C.
10.
11.
12.
Indexed Files
13.
14.
15.
16.
17.
A.
B.
C.
D.
E.
i.
ii.
18.
19.
20.
Sequential Files
21.
22.
Format2
23.
24.
25.
Examples
Format 1 - Start on exact key checking for invalid key
move 1234 to cust-code
start customers key = cust-code
      invalid key display message "Invalid key!"
      not invalid key display message "Started Ok"
Format 1 - Start on key equal or greater than a value
move 956 to cust-code
start customers key not < cust-code
Format 1 - Start on first key of an ISAM file
start customers key is first
Format 1 - Start on last key of an ISAM file
start customers key is last
Format 1 - Start on first record of a sequential file
start customers first
Format 1 - Start on last record of a sequential file
start customers last
Format 2 - Start transaction
   start transaction
   display "Customer to apply 10% discount? "
   accept ws-cust-code
   move ws-cust-code to cust-code
   read customers 
        invalid key display message "Customer not found"
   end-read
   accept ws-date from date
   move ws-date to cust-last-date-discount
   rewrite cust-rec
   move ws-cust-code to inv-cust-code
   start invoices key = inv-cust-code
         invalid key set end-of-invoices to true
         not invalid key set end-of-invoices to false
   end-start
   perform until end-of-invoices
     read invoices next at end exit perform
          not at end 
              if inv-cust-code not = ws-cust-code
     end-read
     if inv-paid-status = "N"
        move 10 to inv-discount
        rewrite invoice-rec
   end-perform
   display "Changes applied, confirm Commit: (Y/N)"
   accept apply-commit
   if apply-commit = "Y"
      commit *> All changes are definitely applied
   else
      rollback *> All changes get undone
   end-if.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left