SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
L-42
Considerations—LOAD
You can use the FIRST KEY value option for every type of file or table except
key-sequenced files or tables.
You should use the FIRST KEY (value, value ...) option only for
key-sequenced files or tables.
You can specify string literals or numeric literals. A string literal occupies as
many bytes as there are characters in the literal. Each numeric literal occupies
one byte.
To specify a value for a CHAR column, enclose the value in quotes. For
example:
FIRST KEY ("value")
To include nondisplayable characters, use the equivalent ASCII numeric form.
This example specifies the BEL control character, with a numeric value of 7 as
the fifth byte in an 8-byte key value:
FIRST KEY ("asdf",7,"jkl")
Be sure to supply enough bytes to fill the column. Pad the string with blanks or
the appropriate pad character for your application.
You must express the value of FIRST KEY value for an Enscribe
entry-sequenced file as 32 bits for block number followed by 32 bits for record
number within the block.
You must express the value in FIRST KEY value for an entry-sequenced
table as 24 bits for sector number followed by 9 bits for the record number
within the block.
To specify a value for a VARCHAR column, handle the value as a CHAR value
and pad the value with blanks (or the appropriate pad character for your
application) to the maximum size of the VARCHAR column.
To specify a value for a binary column (such as SMALLINT, INTEGER, or
LARGEINT), specify as many numeric literals as there are bytes in the column.
For example, each SMALLINT column is two bytes long, so specify two
numbers for each SMALLINT column. To determine the size of your target key
value, look at the binary representation of the key value and determine the
number of 8-bit groups (bytes) in the value.
One way to figure out byte values for positive values is to divide repeatedly by
256 until you reach a quotient of zero, and take the remainders in reverse
order. For example, to represent a value of 1,000,000 for a four-byte INTEGER
column:
1,000,000 divided by 256 is 3906, with a remainder of 64
3,906 divided by 256 is 15, with a remainder of 66
15 divided by 256 is 0, with a remainder of 15