Zero-length character strings
- Last Updated: January 17, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
Zero-length character strings
| ABL value | Oracle equivalent | |
|---|---|---|
"" (zero-length string) |
Default behavior | If -Dsrv PRGRS_MAP_EMPTY_NULL is used |
" " (single space) |
NULL |
|
Store zero-length character string as single-space character
In addition to accepting the unknown operator, Oracle assumes that all
zero-length character strings are unknown and stores them as NULL. However, the OpenEdge Oracle DataServer inserts a zero-length character
string as a single-space character when migrating data from an OpenEdge database to an
Oracle database. Therefore, the Oracle database stores zero-length string values
("") as single-space characters (" ") and unknown values
(?) as NULL. This default behavior of the DataServer
allows OpenEdge applications to distinguish between the unknown value (?)
and zero-length character strings.
When
you use the Unknown value (?) in a WHERE clause
with the DataServer, the Unknown value (?) satisfies only
the equals (=) operator. Both of the following statements find the
first customer record with the Unknown value (?) in the address2 field.
Notice the space between the quotation marks in the first statement:
|
Although "" and " " evaluate the same way
in a WHERE clause, they have different results when you use
them with the BEGINS function. For example, the following
statement retrieves all customer names except those that have the Unknown value (?):
|
The following statement uses " " to retrieve customer
records that have an empty, single, or multi-space string in their names:
|
Because Unknown value (?), or values,
satisfy only the equals condition, the following code does not retrieve
customers with an Unknown value (?) in the address2 field:
|
The following statement is not meaningful to
Oracle. It generates the error, "Illegal operator for Unknown value (?) or
zero-length character string":
|
This restriction has been relaxed for columns
of the DATE data type, as shown in the following
statement:
|
Store zero-length character string as NULL
PRGRS_MAP_EMPTY_NULL option of the DataServer (-Dsrv)
startup parameter instructs the DataServer to map a zero-length string in an OpenEdge
database to a NULL value in an Oracle database. The syntax for the
PRGRS_MAP_EMPTY_NULL option is:
|
PRGRS_MAP_EMPTY_NULL option, because it may cause problems with the
existing Oracle DataServer applications. To utilize this functionality, you do not need to
recompile your applications with ABL virtual machine (AVM) that is OpenEdge release 12.8
or later. You need to provide the PRGRS_MAP_EMPTY_NULL option only. The
absence of this option activates the default behavior.PRGRS_MAP_EMPTY_NULL option, the following statement sets
the value of the char field of the tab table to a zero-length character
string. The Oracle database then converts this zero-length character string to
NULL.
|
char field:
|
|
char field:
|
PRGRS_MAP_EMPTY_NULL option, running a statement with
WHERE clause to retrieve all the single-space character strings fetches
only the single-space character strings. However, in the absence of this option, the same
statement retrieves both, zero-length character strings and single-space character strings.
This is also the default behavior of the DataServer. The BEGINS operator functions differently when you utilize the
PRGRS_MAP_EMPTY_NULL option.
BEGINS with zero-length character strings results in an
error:
|
|
For more information on the differences in DataServer functionality with and without the
PRGRS_MAP_EMPTY_NULL option, see the DataServer default vs. the
PRGRS_MAP_EMPTY_NULL option table .
DataServer default vs. the PRGRS_MAP_EMPTY_NULL option
NULL,
depending on whether the PRGRS_MAP_EMPTY_NULL option is utilized:| Use case | ABL query example | Default behavior | If -Dsrv PRGRS_MAP_EMPTY_NULL is used |
|---|---|---|---|
Insert a zero-length character into the char field of the
tab table. |
|
The Oracle DataServer inserts a single-space character value of the
char field into the Oracle database. Then displays a
zero-length character string when retrieving this record. |
The Oracle DataServer converts the zero-length character value of the
char field to NULL. Then displays an unknown
value (?) when retrieving this record. |
Insert a single-space character into the char field of the
tab table |
|
The Oracle DataServer inserts a single-space character value of the
char field into the Oracle database. |
The Oracle DataServer inserts a single-space character value of the
char field into the Oracle database. |
Retrieve and display records with zero-length characters in the
char field of the tab table using the
WHERE clause |
|
The Oracle DataServer retrieves all single-space character values and converts them into zero-length characters. Then displays the converted values. | The Oracle DataServer retrieves all records with null values and displays
them as unknown values (?). |
Retrieve and display records with single-space character values in the
char field of the tab table using the
WHERE clause |
|
The Oracle DataServer displays all single-space and zero-length character values. | The Oracle DataServer retrieves and displays all single-space character values. |
Retrieve and display records with zero-length character strings in the
address field of the customer table using the
MATCHES operator and the WHERE clause |
|
The Oracle DataServer displays the customer numbers and names of all
customers whose address field contains zero-length, single-space,
or multi-space character strings.The |
The Oracle DataServer displays the following error:
|
Retrieve and display records with single-space character strings in the
address field of the customer table using the
MATCHES operator and the WHERE clause |
|
The Oracle DataServer displays the customer numbers and names of all
customers whose address field contains zero-length and
single-space character strings.The |
The Oracle DataServer displays the customer numbers, names, and address
lengths of all customers whose address field contains
single-space character strings. |
Retrieve and display records with multi-space character strings in the
address field of the customer table using the
MATCHES operator and the WHERE clause |
|
The Oracle DataServer displays the customer number, names, and address length
for all customers whose address field contains multi-space
character strings. |
The Oracle DataServer displays customer numbers, names, and address lengths
of all customers whose address field contains multi-space
character strings. |
Retrieve and display records with NULL (?) character strings
in the address field of the customer table using
the MATCHES operator and the WHERE clause |
|
The Oracle DataServer displays the following error:
|
The Oracle DataServer displays the following error:
|
Retrieve and display records with zero-length character strings in the
address field of the customer table using the
BEGINS operator and the WHERE clause |
|
The Oracle DataServer displays the customer numbers, names, and address lengths of all customers. | The Oracle DataServer displays the following error:
|
Retrieve and display records with single-space character strings in the
address field of the customer table using the
BEGINS operator and the WHERE clause |
|
The Oracle DataServer displays the customer numbers and names of all
customers whose address field contains zero-length, single-space,
or multi-space character strings.The |
The Oracle DataServer displays the customer numbers, names, and address
lengths of all customers whose address field contains
single-space character strings. |
Retrieve and display records with multi-space character strings in the
address field of the customer table using the
BEGIN operator and the WHERE clause |
|
The Oracle DataServer displays the customer number, names, and address
lengths of all customers whose address field contains multi-space
character strings. |
The Oracle DataServer displays the customer numbers, names, and address
lengths of all customers whose address field contains multi-space
character strings. |
Retrieve and display records with NULL (?) character strings
in the address field of the customer table using
the BEGIN operator and WHERE clause |
|
The Oracle DataServer displays the following error:
|
The Oracle DataServer displays the following error:
|
Perform a table join between tab1 and tab2
using the WHERE clause |
|
The Oracle DataServer retrieves all single-space character values for the
tab2.char1 field and converts them into zero-length characters.
Then performs an inner join with the tab1.char1 field using the
retrieved result set. |
The Oracle DataServer retrieves all null values of
tab2.char1 values and then performs an inner join with the
tab1.char1 column using the retrieved result set. |