SQL/MP Programming Manual for COBOL

Explicit Program Compilation
HP NonStop SQL/MP Programming Manual for COBOL529758-003
6-47
SQL Program File
This subsection describes the HOSV and its relationship to the HP COBOL compiler
and SQL compiler. For more information about the PFV and PCV, see the SQL/MP
Version Management Guide.
The HP COBOL compiler generates the HOSV and stores the value in the object file.
If multiple object files are bound together in a single target object file, the HOSV of the
target object file is the newest (maximum) HOSV of the individual object files. For
example, if an object file with an HOSV of 2 and another object file with an HOSV of
310 are bound into a new target object file, the HOSV of the target object file is 310.
To return the HOSV of a program object file, use the GET VERSION OF PROGRAM
statement with the HOST OBJECT option. You can execute this statement from SQLCI
or embedded in a COBOL program. This GET VERSION OF PROGRAM statement is
executed from SQLCI:
GET HOST OBJECT VERSION OF PROGRAM sqlprog;
VERSION: 310
--- SQL operation complete.
To embed a static GET VERSION OF PROGRAM statement in a COBOL program,
you must include the INTO clause with a host variable. This statement returns the
HOSV of SQLPROG to the host variable named HV-HOSV:
EXEC SQL
GET HOST OBJECT VERSION OF PROGRAM SQLPROG INTO :HV-HOSV
END-EXEC.
You can also execute a dynamic GET VERSION OF PROGRAM statement by using
the PREPARE and EXECUTE statements:
MOVE "GET HOST OBJECT VERSION OF PROGRAM SQLPROG" TO HV-TEXT.
EXEC SQL
PREPARE DYNAMIC-STATEMENT FROM :HV-TEXT
END-EXEC.
EXEC SQL
EXECUTE DYNAMIC-STATEMENT RETURNING :HV-HOSV
END-EXEC.
However, you cannot use the GET VERSION OF PROGRAM statement with the
EXECUTE IMMEDIATE statement.
For the syntax of the GET VERSION statement, see the SQL/MP Reference Manual.