PP2 Processes - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

Product
Preprocessor2 for Embedded SQL
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

PP2 includes a precompiler as well as the services that execute or provide runtime support for a compiled application. A precompiler is necessary to interpret the embedded SQL statements in the host program. Regardless of the host language, PP2 operation consists of two stages:

1 The precompile phase, which precedes application compilation and linking.

2 Execution, or runtime support, of the application.

During precompilation, PP2 reads and replaces all the SQL statements embedded in the host program with CLIv2 calls that are acceptable to the native compiler for the host language. The host programming language syntax remains unchanged.

At runtime, the inserted syntax runs in conjunction with Call‑Level Interface version 2 (CLIv2) and Teradata Director Program (TDP) modules to provide a convenient interface between the application program and the Teradata Database.

Note: In a mainframe environment, start a TDP module before PP2 performs the precompile step. Do this even if no data access is required (that is, using NOSYNTAX).

The steps that PP2 performs, from logging on to the Teradata Database through precompilation, are shown below. The example uses a COBOL program, though the process is similar for other languages:

1 Logs a session onto the Teradata Database and determines whether it is to be a Teradata mode or ANSI‑compatible mode session.

2 Checks the syntax of SQL statements in the host language source program, validating database objects against the entries in the Data Dictionary.

3 Builds code in the DATA division for the data elements.

4 Builds code in the PROCEDURE division to handle SQL statement passing to the Teradata Database.

5 Comments out the SQL source code.

6 Produces COBOL source for input to the COBOL compiler.

Figure 1 gives a high‑level view of starting with a PL/I embedded SQL program as the source input file, then precompiling, compiling, linking, and finally, running the PL/I program.

Figure 1: PP2 Operation