Calling Another Procedure

In this section:

How to:

One procedure calls another procedure using:


Top of page

x
Syntax: How to Use the -INCLUDE Command

Lines incorporated with a -INCLUDE are processed as though they had been placed in the calling procedure originally.

-INCLUDE filename

where:

filename

Is the name of the called procedure.

A calling procedure cannot branch to a label in a called procedure, and vice versa.



Example: Using the -INCLUDE Command

In the following example, Dialogue Manager searches for a procedure named DATERPT as specified on the command -INCLUDE.

-IF &OPTION EQ 'S' GOTO PRODSALES
- ELSE GOTO PRODRETURNS;
    .
    .
    .
-PRODRETURNS
-INCLUDE DATERPT
-RUN
    .
    .

Assume that DATERPT contains the following SQL code:

SQL
SELECT PROD_CODE UNIT_SOLD
FROM SALES
WHERE PROD_CODE = '&PRODUCT';
TABLE
ON TABLE PCHOLD
END

Dialogue Manager incorporates this code into the original procedure. It substitutes a value for the variable &PRODUCT as soon as the -INCLUDE is encountered. The ensuing command -RUN executes the SQL request.

The following is an example of a -INCLUDE that calls a partial procedure named OBJECTS:

SQL
SELECT
-INCLUDE OBJECTS
FROM CAR
WHERE RETAIL_COST < 10000;

The procedure OBJECTS contains the fields to use:

COUNTRY,CAR,MODEL

The resulting stacked commands are:

SQL
SELECT
COUNTRY,CAR,MODEL
FROM CAR
WHERE RETAIL_COST < 10000;

Top of page

x
Nesting

Reference:

Any number of different procedures is invoked from a single calling procedure. Nest -INCLUDE commands within each other, up to four levels deep:

-PRODSALES
-INCLUDE FILE1
-RUN
 
        FILE1
        -INCLUDE FILE2
        -RUN
 
                FILE2
                -INCLUDE FILE3
                 -RUN
 
                        FILE3
                        -INCLUDE FILE4
                        -RUN
 
                                FILE4
                                -RUN

Files one through four are incorporated into the original procedure. The server views all of the included files as part of the original procedure.



x
Reference: Other Uses of the -INCLUDE Command

You can also use the -INCLUDE command to:


Top of page

x
The EXEC Command

A procedure also calls another one with the command EXEC. The called procedure must be fully executable.

See Supplying Values for Variables for a description of the syntax.



Example: Using the DATERPT Command

In the following example, a procedure calls DATERPT:

-IF &OPTION EQ 'S' GOTO PRODSALES ELSE GOTO PRODRETURNS;
      .
      .
      .
-PRODRETURNS
   EX DATERPT
      .
      .
      .
-RUN


iWay Software