Using the RAW data type
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Using the RAW data type
ABL supports the RAW data type, which
lets you manipulate raw data without converting it in any way.
You can use the RAW data type to:
- Define ABL variables in an ABL procedure
- Define fields in a OpenEdge database
- Retrieve and manipulate raw data from non-OpenEdge databases
You can use the RAW data type to import non–OpenEdge data
that has no parallel OpenEdge data type. By using the RAW data
type statements and functions, ABL allows you to bring data from
any field into your procedure, manipulate it, and write it back to
the non-OpenEdge database. The functions and statements let you
define RAW data type variables, write data into
a raw variable, find the INTEGER value of a byte, change the length
of a raw variable, and perform logical operations.
The following procedure demonstrates how to retrieve raw values from the database, how to put bytes into variables, and how to write raw values back to the database:
|
This procedure first creates the variable r1 and
defines it as a RAW data type. Next, it finds the
first Customer in the database ("Lift Line Skiing"),
and with the RAW function, takes the raw value
of the Name field, and writes it into the variable r1.
The PUT–BYTE statement then puts the character
code value of "s" (115) into the first byte of r1.
The RAW statement takes the raw value of r1 and
writes it back to the database. Finally, the procedure displays
the Customer name. Thus, "Lift Line Skiing" has
become "sift Line Skiing".
The next procedure shows how you can pull bytes from a field:
|
This procedure finds the Customer with the Customer number
27, and then finds the character code value of each letter in the Customer name.
To do this, it retrieves the bytes from the name one at a time,
then places them into the variable a. The GET–BYTE function returns
the Unknown value (?) if the byte number you try to retrieve
is greater than the length of the expression from which you are retrieving
it. The next procedure demonstrates how you find the length of a
raw value and how to change length of a raw expression:
|
This procedure simply finds the number of bytes in the name of
the first Customer in the database then truncates
the number of bytes to two. The procedure first displays 16 because
the Customer name Lift Line Skiing contains 16
bytes. It then displays 2 because you truncated the raw value to
two bytes.
STRING function
to retrieve a raw value as a string, you must supply a format for
the string as the second function argument.