RDOHELP72.HLB  —  GET
    Assigns values from data records in a record stream to host
    language variables in a program using the RDBPRE preprocessor
    (for BASIC, COBOL, and FORTRAN). You cannot use GET in RDO.
    Example:

    &RDB& FOR E IN EMPLOYEES
    &RDB&     GET
    &RDB&        LAST-NAME = E.LAST_NAME;
    &RDB&        FIRST-NAME = E.FIRST_NAME;
    &RDB&        MIDDLE-INITIAL = E.MIDDLE_INITIAL
    &RDB&     END_GET
    &RDB& END_FOR

1  –  More

    If you have invoked a database, you have the necessary privileges
    to use the GET statement.

    In RDBPRE programs, you can use the GET statement in three ways:

    o  When you establish a record stream with the FOR or START_
       STREAM statement, you use the GET statement to assign values
       from the current record in the stream to variables in your
       program. In the case of START_STREAM, you also need FETCH to
       indicate the current record in the stream.

    o  You can use GET alone, without a FOR or FETCH statement, to
       retrieve the result of a statistical function. The record
       stream is formed by the record selection expression within the
       statistical expression.

    o  Or you can use GET...RDB$DB_KEY in a STORE...END_STORE block
       to retrieve the database key of the record just stored.
       Example:

       &RDB&   STORE E IN EMPLOYEES USING E.EMPLOYEE_ID = 15231;
       &RDB&                              E.LAST_NAME = "Smith";
       &RDB&           GET MY_DB_KEY = E.RDB$DB_KEY;
       &RDB&           END_GET
       &RDB&   END_STORE

       (MY_DB_KEY is a user-defined host language variable.)

    You cannot use the concatenation operation in a GET statement.

                                   NOTE

       Use the GET statement only in RDBPRE programs. RDO uses the
       PRINT statement to display values on the terminal.

2  –  Format

  (B)0GET qwqqqqqqqqq>qqqqqqqqqwqqqqwqqqqqqqq>qqqqqqwqqqk
       mq> handle-options qj    mq>  on-error qqj   x
  lqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqj
  mqwq>  get-item  qqwqq> END_GET qq>
    mqqqqq  ; <qqqqqqj

2.1  –  More

    If you list a field for which the value is null, and there is
    a MISSING_VALUE clause for that field, Oracle Rdb supplies the
    missing value. If there is no MISSING_VALUE clause, and nulls are
    allowed, then Oracle Rdb supplies zeros for numeric fields, blanks
    for text fields, and the OpenVMS base date and time (17-NOV-1858
    00:00:00.00) for date fields.

2.2  –  handle-options

  (B)0handle-options =

  qq> ( qwq> REQUEST_HANDLE qqq> var qqqqqqqqqqqqqqqqqqqqqqqqqqqwq> ) qq>
         tq> TRANSACTION_HANDLE qqq> var qqqqqqqqqqqqqqqqqqqqqqqu
         mq> REQUEST_HANDLE q> var , TRANSACTION_HANDLE q> var qj

2.2.1  –  REQUEST_HANDLE

    A keyword followed by a host language variable. A request handle
    points to the location of a compiled Oracle Rdb request. If you
    do not supply a request handle explicitly, Oracle Rdb associates a
    default request handle with the compiled request. Your must use
    a request handle when you want to make an identical query to two
    different databases.

    In Callable RDO, use !VAL as a marker for host language
    variables.

    You can put parentheses around the host language variable name.

2.2.2  –  TRANSACTION_HANDLE

    A keyword followed by a host language variable. A transaction
    handle identifies each instance of a transaction. If you do not
    declare the transaction handle explicitly, Oracle Rdb attaches an
    internal identifier to the transaction.

    In Callable RDO, use !VAL as a marker for host language
    variables.

    You can put parentheses around the host language variable name.

    Normally, you do not need to use this argument. The ability to
    declare a transaction handle is provided for compatibility with
    other database products and future releases of Oracle Rdb.

2.3  –  on-error

  (B)0ON ERROR qwq> statement qwq> END_ERROR
            mqqqqqqqq<qqqqqj

    on-error

    The ON ERROR clause. This clause specifies the action to be taken
    if an Oracle Rdb error occurs during the GET operation. Request HELP
    for ON_ERROR for more information.

2.4  –  get-item

  (B)0get-item =

    qqqqqqwq> host-variable  = value-expr qqqqqqqqqqqqqqqqwqqq>
          tq> host-variable  = statistical-expr qqqqqqqqqqu
          mq> record-descr   = context-var . * qqqqqqqqqqqj

    Includes an assignment statement specifying a host language
    variable and a database value. The value is assigned to the
    host language variable from the Oracle Rdb value expression or
    statistical expression.

2.4.1  –  host-variable

    A valid variable name declared in the host language program. Ask
    for HELP on Value_expr for more information.

2.4.2  –  statistical-expr

    A statistical expression. A statistical expression calculates
    values based on a value expression for every record in a record
    stream. Ask for HELP on Value_expr for more information.

2.4.3  –  value-expr

    A valid Oracle Rdb value expression. Ask for HELP on Value_expr for
    more information.

3  –  Examples

    Example 1

    The following COBOL example retrieves values from named fields in
    a relation:

    &RDB& START_TRANSACTION READ_WRITE

    &RDB& FOR E IN EMPLOYEES
    &RDB&     GET
    &RDB&        LAST-NAME = E.LAST_NAME;
    &RDB&        FIRST-NAME = E.FIRST_NAME;
    &RDB&        MIDDLE-INITIAL = E.MIDDLE_INITIAL
    &RDB&     END_GET
    &RDB& END_FOR

    &RDB& COMMIT

    This code fragment retrieves field values from each record in
    the EMPLOYEES relation. It assumes that the program has declared
    the three host language variables, LAST-NAME, FIRST-NAME, and
    MIDDLE-INITIAL, with the appropriate data types.

    Example 2

    The following set of statements performs a join of two relations
    and uses GET to retrieve a value from each:

    &RDB& START_TRANSACTION READ_WRITE
    &RDB& FOR JH IN JOB_HISTORY CROSS D IN DEPARTMENTS
    &RDB&       OVER DEPARTMENT_CODE
    &RDB&       WITH JH.JOB_END MISSING
    &RDB&         GET
    &RDB&              ID_NUMBER = JH.EMPLOYEE_ID;
    &RDB&              DEPT-NAME = D.DEPARTMENT_NAME
    &RDB&         END_GET
    &RDB& END_FOR

    &RDB& COMMIT

    Example 3

    The following BASIC code fragment retrieves the result of a
    statistical function:

           INPUT "State:  ", STATE

    &RDB& START_TRANSACTION READ_ONLY

    &RDB&   GET
    &RDB&      NUMBER-EMPLOYEES = COUNT OF E IN EMPLOYEES
    &RDB&                         WITH E.STATE = STATE
    &RDB&   END_GET

          PRINT "Number of employees in ";                &
                     STATE; " is "; NUMBER-EMPLOYEES

    &RDB& COMMIT

    This statement retrieves the number of employees who live in the
    specified state and assigns that number to the variable NUMBER-
    EMPLOYEES.

    Example 4:

    The following RDBPRE program segment uses GET...RDB$DB_KEY within
    a STORE...END_STORE block to retrieve into a host language
    variable the database key of the record about to be stored by
    the STORE statement.

    &RDB&   STORE E IN EMPLOYEES USING E.EMPLOYEE_ID = 15231;
    &RDB&                              E.LAST_NAME = "Smith";
    &RDB&           GET MY_DB_KEY = E.RDB$DB_KEY;
    &RDB&           END_GET
    &RDB&   END_STORE

    (MY_DB_KEY is a user-defined host language variable.)
Close Help