NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
S-47
Examples—SET STYLE
Examples—SET STYLE
The following command activates report headings and specifies an asterisk as the
character to display for null values:
>> SET STYLE HEADINGS ON, NULL_DISPLAY "*";
SETSCALE Function
SETSCALE is a function that specifies the scale of a host variable to SQL. You can use
SETSCALE in SQL statements in C, Pascal, or TAL programs.
You use SETSCALE to store scaled values (such as prices) in a database, retrieve
database values into host variables in the program, or reference values in the database
for comparison operations. The scale information is valid only in the context of the SQL
statement; the program must handle scaling for host language statements.
:host-var
is an integer variable in a host language program.
[INDICATOR] :ind-var
specifies an indicator variable associated with the host variable.
scale
is an integer that specifies the scale of host-var. The values allowed depend on
the size of host-var, as follows:
Considerations—SETSCALE
SETSCALE directs SQL to use host-var in the context of SQL statements as if
host-var were declared with a scale of scale.
If the value in host-var is entered into the database through an INSERT or UPDATE,
the host language program must assign a value that allows for the scale to host-var.
For example, if the program is representing a price of $123.45, then the program should
assign 12345 to host-var and use SETSCALE to specify a scale of two.
If the value is being retrieved from the database through a SELECT operation, SQL
assigns a value that allows for the scale to host-var. For example, if SQL is storing
123.45, then the value 12345 is returned to host-var when the program specifies
SETSCALE with a scale of two in the SELECT statement.
SETSCALE ( :host-var [[INDICATOR] :ind-var], scale )
2-byte integers 0 through 5 decimal digits
4-byte integers 0 through 10 decimal digits
8-byte integers 0 through 18 decimal digits