SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-67
C Examples of INVOKE
This example shows the generated structure template that the previous INVOKE
directive would have generated if the EMPLOYEE table did not contain a user-
defined primary key, such as the EMPNUM column. Note the presence of
SYSKEY:
/* Beginning of generated code for SQL INVOKE */
struct emptbl_rec {
long long syskey;
unsigned short empnum;
struct {
short indicator;
char valu[16];
} first_name;
char last_name[21];
unsigned short deptnum;
};
Use a Guardian physical name for the table in the INVOKE directive. You must
explicitly declare the NAMETYPE as NSK for Guardian physical names, because
the default NAMETYPE is ANSI:
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL DECLARE NAMETYPE 'NSK';
EXEC SQL DECLARE MPLOC '$data07.persnl';
EXEC SQL INVOKE employee AS emptbl_rec NULL STRUCTURE;
struct emptbl_rec emptbl_rec1, emptbl_rec2;
...
EXEC SQL END DECLARE SECTION;
Invoke an SQL table named =classdef and refer to the structure by the identifier
classdef_type. Use a typedef struct statement to define CLASSDEF as the
name of the structure type for the variable row. Use the row variable to access
rows of data from the table:
#pragma section classdef
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INVOKE =classdef AS classdef_type;
typedef struct classdef_type CLASSDEF;
EXEC SQL END DECLARE SECTION;
...
EXEC SQL BEGIN DECLARE SECTION;
CLASSDEF row;
EXEC SQL END DECLARE SECTION;