SQL/MP Programming Manual for C
Host Variables
HP NonStop SQL/MP Programming Manual for C—429847-008
2-13
Date-Time and INTERVAL Data Types
When you use the INVOKE directive for a column with a scaled data type, the 
C compiler generates a comment that shows the scale of the column. For example, 
for price with data type NUMERIC (8,2), INVOKE generates the following: 
long price; /* scale is 2 */
These examples use the =parts DEFINE to represent the PARTS table. The first 
example inserts a new row with the value 98.34 in the PARTS.PRICE column after 
storing the value in the host variable host_var1. The value is multiplied by 100 for 
storing as a whole number.
host_var1 = 9835; 
EXEC SQL INSERT INTO =parts (price)
 VALUES ( SETSCALE (:host_var1, 2) ) ;
The next example updates the PARTS.PRICE column for a disk controller to 158.34. 
The value is multiplied by 100 and stored in the host variable host_var2.
host_var2 = 15834; 
EXEC SQL UPDATE =parts 
 SET price = SETSCALE (:host_var2, 2)
 WHERE parts.partdesc = "disk controller" ;
The next example retrieves the value in the PARTS.PRICE column for a disk controller 
and stores the value in the host variable host_var3. The value has a scale of 2. 
EXEC SQL SELECT parts.price INTO SETSCALE ( :host_var3, 2 )
 FROM =parts
 WHERE parts.partdesc = "disk controller" ;
The next example retrieves the part description for the part with a price of 999.50. The 
PARTS.PRICE value is stored in the host variable host_var4 and passed to NonStop 
SQL/MP in the search condition. The retrieved value is stored in the host variable 
host_varstore.
host_var4 = 99950; 
EXEC SQL SELECT parts.partdesc INTO :host_varstore
 FROM =parts
 WHERE parts.price = SETSCALE (:host_var4,2);
Date-Time and INTERVAL Data Types 
Table 2-3 describes the SQL/MP date-time and INTERVAL data types you can use for 
host variables.
Table 2-3. Date-Time and INTERVAL Data Types (page 1 of 2)
Data Type Description
DATETIME Represents a date and time from year to microsecond (logical subsets, 
such as MONTH TO DAY, are allowed) 
DATE Represents a date and is a synonym for DATETIME YEAR TO DAY










