DTRHELP.HLB  —  Commands Statements Clauses, STORE Statements
       Creates a record in a DEC DATATRIEVE domain and stores values
       in one or more fields of the record. For information on using
       STORE with Oracle CODASYL DBMS and relational databases, see
       the section on the STORE statement for Oracle CODASYL DBMS and
       relational sources in this chapter.

       Format

         STORE  [context-variable IN]  domain-name

          [USING statement-1]

          [VERIFY [USING] statement-2]

1  –  Arguments

    context-variable

       Is the name of the record to be inserted.

    domain-name

       Is the given name or alias of the domain that contains the new
       record.

    USING statement-1

       Specifies a DEC DATATRIEVE statement that can store one value for
       one or more fields in the new record.

    VERIFY [USING] statement-2

       Specifies a statement DEC DATATRIEVE executes just before storing
       the new record.

2  –  Examples

       The following example stores two records in the FAMILIES domain:

       DTR> READY FAMILIES WRITE
       DTR> REPEAT 2 STORE FAMILIES
       Enter FATHER: GEORGE
       Enter MOTHER: SANDY
       Enter NUMBER_KIDS: 2
       Enter KID_NAME: DANA
       Enter AGE: 12
       Enter KID_NAME: DACIA
       Enter AGE: 9

       Enter FATHER: WAYNE
       Enter MOTHER: SHEEL
       Enter NUMBER_KIDS: 2
       Enter KID_NAME: BETE
       Enter AGE: 8
       Enter KID_NAME: ALEX
       Enter AGE: 5
       DTR> FIND FAMILIES WITH MOTHER = "SANDY", "SHEEL"
       [2 records found]
       DTR> PRINT ALL

                             NUMBER    KID
         FATHER     MOTHER    KIDS     NAME    AGE

       GEORGE     SANDY         2   DANA       12
                                    DACIA       9
       WAYNE      SHEEL         2   BETE        8
                                    ALEX        5

       DTR>

       The following example stores a record in the YACHTS domain, using
       a context variable and a VERIFY clause:

       DTR> SHOW HINKLEY_STORE
       PROCEDURE HINKLEY_STORE
       STORE A IN YACHTS USING
       BEGIN
            BUILDER = "HINKLEY"
            MODEL = "BERMUDA 40"
            RIG = "YAWL"
            LOA = 40
            DISP = 20000
            BEAM = 12
            PRICE = 82000
       END VERIFY USING
       BEGIN
            PRINT A.BOAT, SKIP
            IF *.CONFIRMATION CONT "N" THEN
            PRINT SKIP THEN ABORT "BAD RECORD"
       END
       END_PROCEDURE

       DTR> READY YACHTS WRITE
       DTR> :HINKLEY_STORE

                                      LENGTH
                                       OVER
       MANUFACTURER   MODEL     RIG    ALL   WEIGHT BEAM  PRICE

        HINKLEY     BERMUDA 40 YAWL    40    20,000  12  $82,000

       Enter CONFIRMATION: N

       ABORT: BAD RECORD

       DTR>

       The following example defines a domain for single-digit integers
       and their squares, and uses a WHILE statement to control the
       number of records stored in the domain:

       DTR> DEFINE DOMAIN SQUARES USING
       DFN> SQUARES_REC ON SQUARES.DAT;
       DTR> DEFINE RECORD SQUARES_REC USING
       DFN> 01 SQUARES.
       DFN>    03 NUMBER PIC 9.
       DFN>    03 ITS_SQUARE PIC 99.
       DFN> ;
       [Record is 3 bytes long.]
       DTR> DEFINE FILE FOR SQUARES;
       DTR> READY SQUARES WRITE
       DTR> DECLARE N PIC 99.
       DTR> N = 0
       DTR> WHILE N NE 10 STORE SQUARES USING
       CON> BEGIN
       CON>     NUMBER=N
       CON>     ITS_SQUARE = N * N
       CON>     N = N + 1
       CON> END
       DTR> FIND SQUARES
       [10 records found]
       DTR> PRINT ALL

               ITS
       NUMBER SQUARE

         0      00
         1      01
         2      04
         3      09
         4      16
         5      25
         6      36
         7      49
         8      64
         9      81

       DTR>

       The following example stores data from the WORKER domain into
       the expanded NEW_WORKER domain. These domains have duplicate
       elementary field names that are subordinate to different group
       field names. The example uses a FOR statement to control the
       STORE statement so that DEC DATATRIEVE stores the data from the
       elementary fields correctly. The record definitions and the STORE
       statement are as follows:

       DTR> SHOW WORK_REC
       RECORD WORK_REC USING
       01 WORK.
           03 LOCAL.
                05 CITY   PIC X(10).
                05 STATE  PIC X(2).
           03 REMOTE.
                05 CITY   PIC X(10).
                05 STATE  PIC X(2).
       ;
       DTR> SHOW NEW_WORK_REC
       RECORD NEW_WORK_REC USING
       01 WORK.
           03 NEW_LOCAL.
                05 CITY   PIC X(10).
                05 STATE  PIC X(2).
           03 NEW_REMOTE.
                05 CITY   PIC X(10).
                05 STATE  PIC X(2).
           03 NAME.
                05 FIRST PIC X(10).
                05 LAST  PIC X(15).
       ;
       DTR> READY NEW_WORKER WRITE
       DTR> FOR WORKER
       CON>   STORE NEW_WORKER USING
       CON>     BEGIN
       CON>       NEW_LOCAL = LOCAL
       CON>       NEW_REMOTE = REMOTE
       CON>     END
       DTR>
Close Help