FETCH
|
operand1 [operand2 [(parameter)]] |
This document covers the following topics:
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
Related Statements: CALL
| CALL FILE
|
CALL LOOP
|
CALLNAT
|
DEFINE SUBROUTINE
|
ESCAPE
|
FETCH
|
PERFORM
Belongs to Function Group: Invoking Programs and Routines
The FETCH
statement is used to execute a Natural object
program written as a main program. The program to be loaded must have been
previously stored in the Natural system file with a
CATALOG
or
STOW
command. Execution of
the FETCH
statement does not overwrite any source program in the
Natural source work area.
For Natural RPC: See Notes on Natural Statements on the Server (in the Natural Remote Procedure Call (RPC) documentation).
In addition to the parameters passed explicitly with
FETCH
, the fetched program also has access to the established
global data area.
The FETCH
statement may cause the internal execution of an
END TRANSACTION
statement
based on the setting of the Natural profile parameter
OPRB
(Database Open/Close Processing) as set by the Natural administrator. If a
logical transaction is to span multiple Natural programs, the Natural
administrator should be consulted to ensure that the
OPRB
parameter is set correctly.
Operand Definition Table:
Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | yes | no | |||||||||||||||
operand2
|
C | S | A | G | A | U | N | P | I | F | B | D | T | L | G | yes | yes |
Syntax Element Description:
Syntax Element | Description |
---|---|
REPEAT
|
REPEAT Option:
The |
RETURN
|
RETURN Option:
Without the specification of If a program is invoked with |
operand1
|
Program Name:
The name of the program module (maximum 8 characters) can be specified as an alphanumeric constant or the content of an alphanumeric variable of length 1 to 8. Natural will attempt to locate the program in the library currently
active at the time the The program name may contain an ampersand (&); at execution
time, this character will be replaced by the one-character code corresponding
to the current value of the system variable
|
operand2
|
Passing Parameter Fields:
The The parameter fields can be read by the If more parameters are passed than are read by the next
Note: |
parameter
|
Date Format:
If |
** Example 'FETEX1': FETCH (with parameter) ************************************************************************ DEFINE DATA LOCAL 1 #PNUM (N8) 1 #FNC (A1) END-DEFINE * INPUT 10X 'SELECTION MENU FOR EMPLOYEES SYSTEM' / 10X '-' (35) // 10X 'ADD (A)' / 10X 'UPDATE (U)' / 10X 'DELETE (D)' / 10X 'STOP (.)' // 10X 'PLEASE ENTER FUNCTION: ' #FNC /// 10X 'PERSONNEL NUMBER:' #PNUM * DECIDE ON EVERY VALUE OF #FNC VALUE 'A', 'U', 'D' IF #PNUM = 0 REINPUT 'PLEASE ENTER A VALID NUMBER' MARK *#PNUM END-IF VALUE 'A' FETCH 'FETEXAD' #PNUM VALUE 'U' FETCH 'FETEXUP' #PNUM VALUE 'D' FETCH 'FETEXDE' #PNUM VALUE '.' STOP NONE REINPUT 'PLEASE ENTER A VALID FUNCTION' MARK *#FNC END-DECIDE * END
** Example 'FETEXAD': FETCH (called by FETEX1) ************************************************************************ DEFINE DATA LOCAL 1 #PERS-NR (N8) END-DEFINE * INPUT #PERS-NR * WRITE *PROGRAM 'Record added with personnel number:' #PERS-NR * END
** Example 'FETEXUP': FETCH (called by FETEX1) ************************************************************************ DEFINE DATA LOCAL 1 #PERS-NR (N8) END-DEFINE * INPUT #PERS-NR * WRITE *PROGRAM 'Record updated with personnel number:' #PERS-NR * END
** Example 'FETEXDE': FETCH (called by FETEX1) ************************************************************************ DEFINE DATA LOCAL 1 #PERS-NR (N8) END-DEFINE * INPUT #PERS-NR * WRITE *PROGRAM 'Record deleted with personnel number:' #PERS-NR * END
SELECTION MENU FOR EMPLOYEES SYSTEM ----------------------------------- ADD (A) UPDATE (U) DELETE (D) STOP (.) PLEASE ENTER FUNCTION: D PERSONNEL NUMBER: 1150304
Page 1 05-01-13 11:58:46 FETEXDE Record deleted with personnel number: 1150304