DTRHELP.HLB  —  Commands Statements Clauses, ABORT Statement
       Stops the execution of a single statement, an entire procedure,
       or a command file.

       Format

         ABORT  [value-expression]

1  –  Argument

    value-expression

       Is a DEC DATATRIEVE value expression, usually a character string
       literal.

2  –  Examples

       The following example shows how to store a record in the YACHTS
       domain. If the value of the BEAM field is 0, the operation is
       aborted and a message is displayed.

       DTR> STORE YACHTS VERIFY USING
       [Looking for statement]
       DTR> IF BEAM EQ 0 THEN ABORT "Bad value for BEAM"
       Enter MANUFACTURER: AMERICAN
       Enter MODEL: 1980
       Enter RIG: SLOOP
       Enter LENGTH_OVER_ALL: 25
       Enter DISPLACEMENT: 7500
       Enter BEAM: 0
       Enter PRICE: 10000
       ABORT: Bad value for BEAM
       DTR>

       The following example shows how to define a procedure to write a
       report on the current collection and abort the entire procedure
       if there is no current collection to report on.

       DTR> DEFINE PROCEDURE YACHT_REPORT
       DFN> SET ABORT
       DFN> PRINT "HAVE YOU ESTABLISHED A CURRENT COLLECTION?"
       DFN> IF *."YES or NO" CONTAINING "N" THEN
       DFN>      ABORT "SORRY-NO COLLECTION, NO REPORT."
       DFN> REPORT
       DFN> PRINT BOAT
       DFN> AT BOTTOM OF REPORT PRINT COUNT, TOTAL PRICE
       DFN> END_REPORT
       DFN> END_PROCEDURE
       DTR> :YACHT_REPORT

       HAVE YOU ESTABLISHED A CURRENT COLLECTION?
       Enter YES or NO: NO
       ABORT: SORRY--NO COLLECTION, NO REPORT.
       DTR>

       In the following example, a procedure is defined to update the
       OWNERS domain after the sale of a boat. The boat is checked
       against the inventory in the YACHTS domain and the procedure
       is aborted if the boat is not in YACHTS. Then, the OWNERS domain
       is checked for a record of the boat. If a record exists, the
       owner's name is changed and the boat name is updated, if desired.
       If no record exists, a new record is stored in the OWNERS domain.
       The procedure requires MODIFY or WRITE access to OWNERS for the
       update and EXTEND or WRITE access for the entry of a new record.

       The example aborts because there is no YACHTS record for an
       ALBERG 42. The value expression specified in the ABORT statement
       includes the variables BLD and MOD.

       DTR> SHOW SALE_BOAT
       PROCEDURE SALE_BOAT
       READY YACHTS, OWNERS WRITE
       SET ABORT
       DECLARE BLD PIC X(10).
       DECLARE MOD PIC X(10).
       BLD = *."BUILDER'S NAME"
       MOD = *."MODEL"
       IF NOT ANY YACHTS WITH (BUILDER = BLD AND
              MODEL = MOD) THEN
              BEGIN
                 PRINT SKIP, "RECORD NOT FOUND IN YACHTS.", SKIP
                 ABORT "POSSIBLE INVENTORY ERROR FOR--"||BLD|||MOD
              END ELSE
              PRINT SKIP, "YACHTS RECORD FOUND FOR "|BLD|||MOD
       IF ANY OWNERS WITH (BUILDER = BLD AND
              MODEL = MOD) THEN
              BEGIN
                 FOR OWNERS WITH (BUILDER = BLD AND
                    MODEL = MOD)
                 MODIFY USING
                    BEGIN
                       PRINT COL 10, NAME, SKIP
                       NAME = *."NEW OWNER'S NAME"
                       PRINT COL 10, BOAT_NAME, SKIP
                       IF *."CHANGE BOAT NAME? Y/N"
                          CONTAINING "Y" THEN PRINT SKIP THEN
                          BOAT_NAME = *."NEW BOAT NAME"
                       END
              END ELSE

              STORE OWNERS USING
              BEGIN
                 NAME = *."NEW OWNER'S NAME"
                 BOAT_NAME = *."BOAT NAME"
                 BUILDER = BLD
                 MODEL = MOD
              END
       END_PROCEDURE
       DTR> :SALE_BOAT
       Enter BUILDER'S NAME: ALBERG
       Enter MODEL: 42
       RECORD NOT FOUND IN YACHTS.
       ABORT: POSSIBLE INVENTORY ERROR FOR--ALBERG 42
       DTR>
Close Help