SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)
Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL—663854-002
3-36
Host Variables in C Structures
If the interval string length is larger than the number of digits in the interval value, you
must blank pad up to the null terminator. See Inserting or Updating Fixed-Length
Character Data on page 3-15.
Host Variables in C Structures
When you refer to a single field name in a structure, you must include the structure
name with the field name.
Example
This example uses a structure named employee_info, containing the empnum and
empname fields:
EXEC SQL BEGIN DECLARE SECTION;
struct employee {
unsigned short empnum;
char empname[21];
} employee_info;
EXEC SQL END DECLARE SECTION;
To use a field as a host variable in an SQL statement, refer to the field by using the
structure names:
EXEC SQL SELECT empnum, empname
INTO :employee_info.empnum, :employee_info.empname
... ;
Host Variables as Data Members of a C++ Class
You can include an SQL Declare Section within a class definition to use a data
member of a class as a host variable.
Example
This example uses a class named jobsql, containing the declarations of the
memhv_jobcode and memhv_jobdesc host variables. These host variables are
referenced in the member function putjob defined in the class:
class jobsql {
// Class member host variables
EXEC SQL BEGIN DECLARE SECTION;
unsigned NUMERIC (4) memhv_jobcode;
VARCHAR memhv_jobdesc[19];
EXEC SQL END DECLARE SECTION;
public:
void putjob(){
EXEC SQL
INSERT INTO persnl.job
VALUES (:memhv_jobcode, :memhv_jobdesc);
}
}; // End of jobsql class definition
main(){
...
C
C++










