SQL Programming Manual for TAL
NonStop SQL Version Issues
HP NonStop SQL Programming Manual for TAL—527887-001
D-14
Using the Single-Code Thread Design
Using the Single-Code Thread Design
To develop a program that can run on a node running NonStop SQL release C10 and a
node running NonStop SQL release C30 software and use Version 2 features, follow
these steps:
1. In static SQL statements, do not use Version 2 features and objects. Static SQL
statements will be processed by both the release C10 and C30 SQL compilers.
2. Use Version 2 features and objects only in dynamic SQL statements.
In dynamic SQL operations, only the host variables that contain the SQL
statements are processed by the TAL compiler. The actual SQL statements are
represented as text in the host variables and therefore are not explicitly SQL
compiled.
3. For dynamic SQL statements:
•
Generate both NonStop SQL release C10 and C30 SQLDA structures.
•
When your program first begins executing (that is, before you issue an SQL
query), check the NonStop SQL software version using an SQL system
procedure. Then, depending on this version, initialize and use the appropriate
SQLDA structure.
•
Ensure that a dynamic SQL statement that uses VersionÊ2 features executes
only within a code branch that handles VersionÊ2 features. For example:
IF sw^version = version^2 THEN
host^var ':=' "SELECT * FROM t1 UNION SELECT * FROM t2"
ELSE
host^var ':=' "SELECT * FROM t1";
EXEC SQL PREPARE statement FROM :host^var;
4. Compile your TAL source statements using a release C30 TAL compiler. Specify
the SQL directive with the RELEASE1 option as the first line of your primary
source file or in the RUN command line for the TAL compiler.
The RELEASE1 option causes the TAL compiler to generate release C10 SQLDA
structures and object code that is compatible with both the release C10 and C30
SQL compilers. (Object code and structures generated with the RELEASE2 option
are not compatible with the release C10 SQL compiler.)
5. SQL compile and distribute the program for installation and use on production
nodes as follows:
•
For C30 nodes, SQL compile and test the program on a C30 node and then
distribute the program object file to any other C30 nodes.
•
For C10 nodes, SQL compile and test the program on a C10 node and then
distribute the program object file to any other C10 nodes.