Assigns values from data records in a record stream to host variables in RDML programs. You can use the GET statement in three different 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 the START_STREAM statement, you also need a FETCH statement to indicate the current record in the stream. o You can use GET within a STORE operation to retrieve the value of the record currently being stored. This includes the use of GET ... RDB$DB_KEY in a STORE ... END_STORE block to retrieve the database key (dbkey) of a record just stored. o You can also use the GET statement alone, without a FOR, FETCH, or STORE statement to retrieve the result of a statistical expression. The record stream is formed by the record selection expression within the statistical expression.
1 – Examples
The following examples demonstrate the use of the GET statement with a statistical function. The examples store the value of the statistical function in the host language variable maxi, then print this value.
1.1 – C Example
#include <stdio.h> DATABASE PERS = FILENAME "PERSONNEL"; DECLARE_VARIABLE maxi SAME AS PERS.CURRENT_INFO.SALARY; main() { READY PERS; START_TRANSACTION READ_ONLY; GET maxi = MAX CI.SALARY OF CI IN CURRENT_INFO; END_GET; printf ("%f",maxi); COMMIT; FINISH; }
1.2 – Pascal Example
program max_function (input,output); DATABASE PERS = FILENAME 'PERSONNEL'; DECLARE_VARIABLE maxi SAME AS PERS.CURRENT_INFO.SALARY; begin READY PERS; START_TRANSACTION READ_ONLY; GET maxi = MAX CI.SALARY OF CI IN CURRENT_INFO; END_GET; writeln (maxi:10:2); COMMIT; FINISH; end.
2 – Format
(B)0[mget-statement = [4mGET[m qqwqqqq>qqqqqqqqwqqwq> get-item qqwqqqqq> [4mEND_GET[m qqq> mq> on-error qj mqqqqq ; <qqqqqqj (B)0[mget-item = qqqqwqq> host-var qqqqqqqq> = qqqqq> value-expr qqqqqqqqqqwqqqq> tqq> record-descr qqqq> = qqqqq> context-var.* qqqqqqqu mqq> host-var qqqqqqqq> = qqqqq> statistical-expr qqqqj
2.1 – Format arguments
on-error The ON ERROR clause. Specifies host language or RDML statement(s) to be performed if an error occurs during the GET operation. For more information see the entry on ON ERROR. get-item The GET statement includes an assignment statement specifying a host variable and a database value. The database value is assigned to the host variable from the Oracle Rdb value expression or statistical expression. Note that the GET statement must be the last statement before END_STORE when it is used in a STORE ... END_STORE block. host-var A valid variable name declared in the host program. value-expr A valid RDML value expression. The value expression can include the "<context- variable>.RDB$DB_KEY" expression. record-descr A valid host language record descriptor that contains an entry for each field in the relation. Each field of the record descriptor must match exactly the field names and data types of the fields in the Oracle Rdb relation referenced by the context variable. context-var A context variable. A temporary name that you associate with a relation. You define a context variable in a relation clause. For more information see the entry on Context Variables. statistical-expr A statistical expression; calculates values based on a value expression for every record in the record stream.