
Host Variables
HP NonStop SQL/MP Programming Manual for C—429847-008
2-12
Fixed-Point Data Types
To select database values into host variables
To refer to values stored in the database for comparisons
The SETSCALE function has this syntax:
host-variable
is an integer host variable.
indicator-variable
is an indicator variable associated with the host variable.
scale
specifies the scale of
host-variable.
The values for
scale
depend on the size
of
host-variable
:
Follow these guidelines when you use the SETSCALE function:
If you are transferring a value from a host variable to a database using an INSERT
or UPDATE statement, you must assign a value to the host variable that allows for
the scale. For example, to insert a price of $123.45, assign 12345 to hostvar and
specify a scale of 2.
If you are retrieving a value from a database using a SELECT statement, NonStop
SQL/MP returns a value that allows for the scale in the host variable
.
For
example, if your program specifies a scale of 2 in the SELECT statement and
123.45 is stored in the database, SQL/MP returns 12345 to the host variable.
The scale is valid only for SQL statements. If you use the SETSCALE function in
SQL statements and the host variables in calculations using C statements, the
C statements must handle the scale.
To use SETSCALE in an expression, apply the SETSCALE function to each
operand individually rather than to the result of the expression. For example, this
expression adds two prices with a scale of 2 decimal places:
SETSCALE (:price1, 2) + SETSCALE (:price2, 2)
SETSCALE (:
host-variable
[ [ INDICATOR ] :
indicator-variable
] ,
scale
)
Size Values
2-byte integers
0 – 5 decimal digits
4-byte integers
0 – 10 decimal digits
8-byte integers
0 – 18 decimal digits
Содержание NonStop SQL/MP
Страница 4: ......
Страница 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Страница 34: ...Introduction HP NonStop SQL MP Programming Manual for C 429847 008 1 8 SQL MP Version Management ...
Страница 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Страница 68: ...SQL MP Statements and Directives HP NonStop SQL MP Programming Manual for C 429847 008 3 8 Finding Information ...
Страница 156: ...Explicit Program Compilation HP NonStop SQL MP Programming Manual for C 429847 008 6 40 SQL Program Files ...
Страница 264: ...Dynamic SQL Operations HP NonStop SQL MP Programming Manual for C 429847 008 10 66 Detailed Dynamic SQL Program ...
Страница 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...
Страница 300: ...Memory Considerations HP NonStop SQL MP Programming Manual for C 429847 008 B 6 Avoiding Memory Stack Overflows ...
Страница 304: ...Maximizing Local Autonomy HP NonStop SQL MP Programming Manual for C 429847 008 C 4 Skipping Unavailable Partitions ...