SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
3-36
Date-Time and Interval Data
The TIME default precision is 0 (zero), and the TIMESTAMP default precision is 6.
Example
If a database has a BILLINGS table that consists of the CUSTNUM and
BILLING_DATE columns, this example selects the date-time value:
EXEC SQL BEGIN DECLARE SECTION;
struct billing_rec {
unsigned short hv_custnum;
DATE hv_billing_date;
...
} bill;
...
EXEC SQL END DECLARE SECTION;
...
EXEC SQL SELECT custnum, billing_date
INTO :bill.hv_custnum, :bill.hv_billing_date
FROM billings
WHERE custnum = :hv_this_customer;
... bill.hv_billing_date[10]='\0';
Inserting or Updating Standard Date-Time Values
To insert or update standard date-time values (DATE, TIME, or TIMESTAMP, or the
SQL/MP DATETIME equivalents) in the database, format the date-time values in the
desired display format for a date, time, or timestamp. Within an INSERT or UPDATE
statement, use the DATE, TIME, or TIMESTAMP data type.
Example
If a database has a BILLINGS table that consists of the CUSTNUM and
BILLING_DATE columns, this example inserts a customer number and date-time value
into that table:
EXEC SQL BEGIN DECLARE SECTION;
struct billing_rec {
unsigned short hv_custnum;
DATE hv_billing_date;
...
} bill;
...
EXEC SQL END DECLARE SECTION;
...
bill.hv_billing_date[10]='\0';
...
EXEC SQL INSERT INTO billings
VALUES (:bill.hv_custnum, :bill.hv_billing_date);
...
C
C