SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
L-43
Considerations—LOAD
To specify 1,000,000 as a four-byte INTEGER value, start with 0, followed by
15, 66, and 64:
FIRST KEY (0,15,66,64)
This example specifies a key value for a table with a four-column key of
varying types: CHAR(2), SMALLINT, CHAR(1), and SMALLINT, starting at the
values “ab”, 20, “x” and 10:
FIRST KEY ("ab", 0, 20, "x", 0, 10)
The byte string in this example is 7 bytes long—one byte for each ASCII
character and one byte for each numeric value.
To specify a value for a numeric column (such as NUMERIC(n),
NUMERIC(n,m), PIC ((n) COMP, or PIC 9(n) COMP), determine whether the
value is represented as 2, 4, or 8 bytes. Adjust the number to an integer value
by multiplying by one factor of 10 for each digit after the implied decimal point,
then determine the number of 8-bit groups in the value. Specify each byte,
separated by commas.
This example specifies a value of 10.5 for a column declared as
NUMERIC(6,2) or PIC 9999V99 COMP:
FIRST KEY (0,0,4,26)
There are two digits after the implied decimal point, so multiply the value by
10**2 (or 100) to get 1050. Convert 1050 to byte values, to get 4,26.
To specify an unsigned decimal column (such as DECIMAL(n) UNSIGNED),
enter the value as a string, like a CHAR value. If the value includes a fraction,
omit the decimal point but enter all digits, including leading and trailing zeros.
To specify a negative value for a signed decimal column (such as DECIMAL(n)
or PIC S9(n)), specify the value as a numeric byte value with the initial bit set
and the remaining characters as ASCII. To do this, take the byte value of the
first digit (for example, 0 is an ASCII 48) and add it to 128, the value obtained
with the high-order bit set. Specify the remaining bytes in quotes.
This example specifies a value of -10 for a DECIMAL(4) field:
FIRST KEY (176,"010")
To specify a positive value for a signed decimal column, use the guidelines
described previously for unsigned decimal columns.
To specify a value for a DATETIME column, use numeric byte values. The year
is stored in two bytes; the other parts are stored in one byte each. The fraction
is stored in four bytes. SQL stores only the portion of the DATETIME field that
is declared for the column.
This example specifies a value of 1993-03-01 for a DATETIME YEAR TO DAY
column:
FIRST KEY (7,201,3,1)