VMS Help  —  RDML72  Statements  STORE Seg Strings
    Stores a segmented string into a segmented string field. Must be
    nested within a regular STORE statement.

1  –  Examples

    The following programs demonstrate the use of the STORE statement
    to store segmented strings in a record. These programs:

    o  Declare an array to hold the segmented strings to be stored.

    o  Assign values to the array.

    o  Use a STORE operation to store the employee ID in the RESUMES
       record.

    o  Use an inner STORE operation to store the segmented strings.
       This ensures that the employee ID and the segmented strings
       are stored in the same record.

    o  Store the values from the array into the RESUME field of
       RESUMES.

    o  Complete the STORE operation.

    o  Retrieve the segmented strings (just stored) using a nested
       FOR statement.

    For more information on retrieving segmented strings, see the
    entry on FOR Seg_String.

1.1  –  C Example

    #include <stdio.h>
    DATABASE PERS = FILENAME "PERSONNEL";

    main()
    {
    int line;
    char *document[3];

    document[0] = "first line of resume  ";
    document[1] = "second line of resume ";
    document[2] = "last line of resume   ";

    READY PERS;
    START_TRANSACTION READ_WRITE;

        STORE R IN RESUMES USING
            strcpy (R.EMPLOYEE_ID,"12345");
                             for (line = 0; line <= 2; line++)
                STORE LINE IN R.RESUME
                                     strcpy(LINE.VALUE,document[line]);
                    LINE.LENGTH = strlen(LINE.VALUE);
                END_STORE;
        END_STORE;

    FOR R IN RESUMES WITH R.EMPLOYEE_ID = "12345"
        FOR LINE IN R.RESUME
          printf("%s\n",LINE.VALUE);
        END_FOR;
    END_FOR;

    COMMIT;
    FINISH;
    }

1.2  –  Pascal Example

    program segstr (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';

    type                     lines = varying [80] of char;
    var                      linecnt  : integer;
                             document : array [0..2] of lines;

    begin

    document[0] := 'first line of resume  ';
    document[1] := 'second line of resume ';
    document[2] := 'last line of resume   ';

    READY PERS;
    START_TRANSACTION READ_WRITE;

    STORE R IN RESUMES USING
       R.EMPLOYEE_ID:= '12345';
       for linecnt := 0 to 2 do
           STORE SEG IN R.RESUME
                               SEG  := document[linecnt];
                               SEG.LENGTH := length(document[linecnt]);
            END_STORE;
    END_STORE;

    COMMIT;

    START_TRANSACTION READ_WRITE;

    FOR R IN RESUMES WITH R.EMPLOYEE_ID = '12345'
        FOR SEG IN R.RESUME
          writeln(SEG);
        END_FOR;
    END_FOR;

    COMMIT;
    FINISH;
    end.

2  –  Format

  (B)0STORE qqqqqwq>qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq>qqwqqqqqqqk
             mq> ( qq> TRANSACTION_HANDLE qq  var qq>  )qj       x
        lqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqj
        mqq> ss-handle  qqq> IN qqqq> ss-field qqqqqqqqqqqqqqqqqqk
        lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqj
        mqq> USING qqqwq>qqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqk
                      mq> on-error qqj                  x
        lqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
        mqqqqqqqqqqqqqqqq assignment qqqqqqqqqqqq>qqqqqqk
                                                        x
        lqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqj
        mqqqq> END_STORE qqqqq>

2.1  –  Format arguments

    TRANSACTION_HANDLE     The TRANSACTION_HANDLE keyword followed by
    var                    a host language variable. A transaction
                           handle identifies a transaction. If
                           you do not supply a transaction handle
                           explicitly, RDML uses the default
                           transaction handle.

    ss-handle              A segmented string handle. A name that
                           identifies the segmented string.

    ss-field               A qualified field name that refers to a
                           field defined with the SEGMENTED STRING
                           data type. Note that this field name, like
                           all field names in a FOR statement, must
                           be qualified by its own context variable.
                           This second context variable must match
                           the variable declared in the outer FOR
                           statement. See the Examples entry.

    on-error               The ON ERROR clause. Specifies host
                           language statement(s) to be performed
                           if an error occurs during the STORE
                           operation. For more information see the
                           entry on ON ERROR.

    assignment             Associates the two database variables with
                           a value expression. The database variables
                           refer to the segment of a segmented string
                           and its length. The special name for
                           the segment can be either "VALUE" or
                           "RDB$VALUE". The special name for the
                           segment length can be either "LENGTH"
                           or "RDB$LENGTH". You cannot assign any
                           other database variables to the value
                           expressions for segmented strings. The
                           assignment operator for RDML Pascal is
                           ":=" and for RDML C is "=" or strcpy.
Close Help