Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE displayCustomer:
- DEFINE PARAMETER BUFFER bfCustomer FOR Customer.
- IF NOT AVAILABLE bfCustomer THEN
- DO:
- MESSAGE 'No Customer Available'
- VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
- END.
- DISPLAY bfCustomer.CustNum bfCustomer.NAME bfCustomer.City.
- END PROCEDURE.
- PROCEDURE updateCustomer:
- DEFINE PARAMETER BUFFER bfCustomer FOR Customer.
- IF NOT AVAILABLE bfCustomer THEN
- DO:
- MESSAGE 'No Customer Available'
- VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
- END.
- IF INDEX (bfCustomer.NAME, 'Update' ) = 0 THEN
- DO:
- bfCustomer.NAME = bfCustomer.NAME + 'Update'.
- END.
- ELSE DO:
- bfCustomer.NAME = SUBSTRING (bfCustomer.NAME, 1, INDEX (bfCustomer.NAME, 'Update' ) - 1).
- END.
- END PROCEDURE.
- PROCEDURE fetchCustomersFromCity:
- DEFINE INPUT PARAMETER ipcCity AS CHARACTER NO-UNDO.
- DEFINE BUFFER bfCustomer FOR Customer.
- DEFINE QUERY qQueryAllCust FOR bfCustomer.
- DEFINE VARIABLE iCountCustomer AS INTEGER NO-UNDO.
- OPEN QUERY qQueryAllCust FOR EACH bfCustomer NO-LOCK WHERE bfCustomer.City = ipcCity.
- GET FIRST qQueryAllCust NO-LOCK.
- DO WHILE NOT QUERY-OFF-END('qQueryAllCust'):
- iCountCustomer = iCountCustomer + 1.
- IF iCountCustomer = 5 THEN
- DO:
- RUN updateCustomer(BUFFER bfCustomer).
- END.
- /*We have to get an Exclusive Lock on the fifth customer so we can update */
- IF iCountCustomer = 4 THEN
- DO:
- RUN displayCustomer(BUFFER bfCustomer).
- GET NEXT qQueryAllCust EXCLUSIVE-LOCK.
- END.
- ELSE DO:
- RUN displayCustomer(BUFFER bfCustomer).
- GET NEXT qQueryAllCust NO-LOCK.
- END.
- END.
- CLOSE QUERY qQueryAllCust.
- END PROCEDURE.
- RUN fetchCustomersFromCity (INPUT 'Akron').
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement