Preparing Programs for Static Execution

#### Search Results

Search

# Preparing Programs for Static Execution

The static generation for NDZ is independent from the static generation of NDB. This means that Natural programs can be generated static for NDZ. Their SQL statements are placed in a SQLJ profile, the SQLJ profile name and the SQLJ sequence numbers are stored into Natural objects for static execution, and a package containing the SQL statements is bound in Db2.

Independently from the NDZ static generation, Natural programs can be generated statically for NDB. Their SQL statements are precompiled in an assembler program, the DBRM name and the section and statement numbers are stored into the Natural objects for static execution, and a package containing the SQL statements is bound in Db2.

The Natural programs subject to NDZ static generation and NDB static generation don't have to be identical. However, one Natural program can only be in one SQLJ profile and/or in one NDB DBRM/PACKAGE. The following graphic shows an NDZ static generation done for Natural programs PROG1 and PROG2 contained in the SQLJ profile and package PROF1 and an NDB static generation done for Natural programs PROG2 and PROG4 contained in package PACK1.

The following information describes the steps of the NDZ static generation as delivered in the NDZSTATG job of the installation.

- Step 1 – GENERATE

- Step 2 – GENSQLJ

- Step 3 – GENPROF

- Step 4 - MODIFYZ

- Step 5 – BINDSQLJ

- Shell Scripts for static preparation

- Comparison Between NDZ and NDB Static Generation

## Step 1 – GENERATE

The first step is about Natural Batch and is identical to the first step of the NDB static generation. The `CMD CREATE DBRM` command creates an SQL assembler program. For details look into the NDB documentation, section Generation Procedure: CMD Create Command.

## Step 2 – GENSQLJ

You must convert the temporary assembler program generated in Step 1 to a SQLJ program. The Java program `com.softwareag.ndz.sqljgen.SQLJGenerator` is provided to perform this conversion. You must use IBM JZOS Batch Launcher to execute this program.

#### Input Parameters

`DBRM name` – the name of the generated SQLJ program. This name has to be the same as the one used in Step 1.

#### DD Names

`INPUT` – The temporary assembler program generated in step 1.

`OUTPUT` – The temporary SQLJ program.

JCL Example:

    //GENSQLJ  EXEC PROC=JVMPRC86,REGSIZE=1024M,
    //         JAVACLS='com.softwareag.ndz.sqljgen.SQLJGenerator'
    //INPUT    DD DSN=&&TMP6,DISP=(OLD,PASS)
    //OUTPUT   DD PATH='&NDZPATH./static/&PROFILE..sqlj',
    //         PATHDISP=(KEEP,DELETE),
    //         PATHOPTS=(OCREAT,ORDWR),
    //         PATHMODE=(SIRUSR,SIWUSR,
    //             SIRGRP,SIWGRP,
    //             SIROTH,SIWOTH),
    //         FILEDATA=TEXT
    //MAINARGS DD *,SYMBOLS=JCLONLY
    &PROFILE
    //STDENV   DD *,SYMBOLS=JCLONLY
    . /etc/profile
    . &NDZPATH./bin/setenv.sh

    /*

## Step 3 – GENPROF

Then you must use the IBM Db2 SQLJ Translator (sqlj) to generate an SQLJ profile using the SQLJ program generated in the previous step as input. You can call the SQLJ translator with the provided IBM Db2 class `sqlj.tools.Sqlj`. You must use the IBM JZOS Batch Launcher to execute this program.

JCL Example:

    //GENPROF  EXEC PROC=JVMPRC86,REGSIZE=1024M,
    //         JAVACLS='sqlj.tools.Sqlj'
    //MAINARGS DD *,SYMBOLS=JCLONLY
    -compile=true -d=&NDZPATH./static
    &NDZPATH./static/&PROFILE..sqlj
    //STDENV   DD *,SYMBOLS=JCLONLY
    . /etc/profile
    . &NDZPATH./bin/setenv.sh

    /*

OR

You can use the provided shell script `genprof.sh` to complete this step. The script is located in the `bin` subdirectory of your NDZ installation.

    Usage: genprof <NDZ_PATH> <program>

## Step 4 - MODIFYZ

You must then modify the Natural programs with the SQLJ profile name and the SQLJ sequence numbers using the `CMD MODIFYZ` command. Input the temporary assembler program created during the first step.

## Step 5 – BINDSQLJ

Lastly, use the NDZ SQLJ Profile binder, `com.softwareag.ndz.sqljbinder`, to bind packages for the SQLJ Profile generated in the previous step. You must use the IBM JZOS Batch Launcher to execute this program.

JCL Example:

    //BIND     EXEC PROC=JVMPRC86,REGSIZE=1024M,
    //         JAVACLS='com.softwareag.ndz.sqljbinder.Main'
    //MAINARGS DD *,SYMBOLS=JCLONLY
    -profile &PROFILE -bindoptions &BINDOPTS
    //STDENV   DD *,SYMBOLS=JCLONLY
    . /etc/profile
    . &NDZPATH./bin/setenv.sh
    /*

OR

You can use the provided shell script `bind.sh` to complete this step.

    Usage: bind <NDZ_PATH> <url> <user> <password> <program> <bind_opts>

## Shell Scripts for static preparation

`setenv.sh` – Sets the environment variables for Java, Db2, and NDZ. The variables are required by other scripts.

`genprof.sh` – Generates profiles for static execution. Syntax:

    genprof ndz_path program

Where ndz_path is the NDZ installation path and program is the SQLJ program that is used to generate the profile.

`bind.sh` – Binds a static profile to Db2.

Syntax:

    bind NDZ_PATH url user password program bind_opts

Where ...

- NDZ_PATH is the installation path of NDZ.

- url is the URL for Db2 access.

- user is the username for Db2 access.

- password is the password for the selected username for Db2 access.

- program is the Natural program that is accessing Db2.

- bind_opts is a list of bind options. Every option has to be seperated by a space and carries the same function as Db2 precompile and bind options. For more information, see the BIND PACKAGE command section in the IBM Db2 documentation.

## Comparison Between NDZ and NDB Static Generation

The following table compares the different steps of NDZ static generation and NDB static generation.

Step # | NDZ Static Generation | NDB Static Generation
--- | --- | ---
Step 1 | `GENERATE` – generate temporary SQL assembler program using `CMD CREATE DBRM`. | `GENERATE/GENERATION` – generate temporary SQL assembler program using `CMD CREATE DBRM`.
Step 2 | `GENSQLJ` – generate temporary SQLJ program. | This step is omitted in NDB Static Generation.
Step 3 | `GENPROF` – generate the SQLJ profile. | `PC` – Db2 precompiles the SQL assembler program.
Step 4 | `MODIFYZ` – modify the Natural programs with SQLJ profile numbers and SQLJ sequence numbers using `CMD MODIFYZ` | `MODIFY` – modify Natural programs with DB2 DBRM name and section and statement numbers using `CMD MODIFY`
Step 5 | `BINDSQLJ`– place static SQL information into DB2 to BIND PACKAGE. | `BIND`– place static SQL information into DB2 to BIND PACKAGE.

### On this page

- Step 1 – GENERATE
- Step 2 – GENSQLJ
- Step 3 – GENPROF
- Step 4 - MODIFYZ
- Step 5 – BINDSQLJ
- Shell Scripts for static preparation
- Comparison Between NDZ and NDB Static Generation