SQL Programming Manual for Pascal
Host Variables and Parameters
HP NonStop SQL Programming Manual for Pascal—528614-001
2-7
Using Host Variables
For inserting null values, the programmer sets the value of the indicator variable to
any value less than zero.
TYPE AS
indicates that values in the host variable will have the specified date-time data
type. A host variable that is to contain date or time values must be defined with a
character data type.
Using the SETSCALE Function
If you must ensure that a database column size matches the host variable size (for
example, you might be transferring data between a NonStop SQL database and an
Enscribe file), use a Pascal numeric data type that corresponds to the data type of the
SQL column. You can use the INVOKE directive and then use the SETSCALE function
to communicate the scale between the Pascal and SQL statements.
If you use the SETSCALE function and your program must also use the host variables
in calculations, include the necessary code to scale the values in the host variables.
The SETSCALE function has this syntax:
: host-variable
is a numeric host variable.
INDICATOR :indicator-variable
is an indicator variable associated with the host variable. For more information
about using indicator variables to specify or read null values, see Using Date-Time
and INTERVAL Data in Host Variables on page 2-9.
scale
designates the scale of :host-variable. The values allowed for scale depend on the
size of :host-variable as follows:
The SETSCALE function causes NonStop SQL to use :host-variable in the context of
SQL statements as if :host-variable were declared with a scale of scale. For example,
the sequence SETSCALE (hostvar, n) causes NonStop SQL to interpret host variable
hostvar as:
hostvar * 10-n
SETSCALE (: host-variable
[ [INDICATOR] :indicator-variable ] , scale )
Size Pascal Type Values Allowed
2-byte integers INT16 0 - 5 decimal digits
4-byte integers INT32 0 - 10 decimal digits
8-byte integers INT64 0 - 18 decimal digits