predicates
Predicates are comparisons of the contents of a field, column, or (start:end) string to a constant, as shown in the following examples.
LOADPLUS uses predicates as part of WHEN, NULLIF, and DEFAULTIF syntax. Predicate operation differs based on the value of the RULES installation option.
Predicate examples
(1:6)¬=X'00000000000C'
INT_COL > 5
The following table defines how we use the terms fieldName and columnName when describing the left side of a predicate. The sections that follow this table describe these specifications in more detail.
Name | Description |
---|---|
fieldName | A name included in a field specification that does not correspond to a column in the table that you are loading |
columnName | A column of the table that you are loading This column must be included in a field specification unless you also specify FORMAT BMC, FORMAT UNLOAD, or FORMAT BMCUNLOAD. |
fieldName
When you specify a name on your predicate and no column of the same name exists in the table that you are loading, LOADPLUS assumes that you have specified a field name. This field name must be included in your field specification and the length of the field must be less than or equal to 255.
Restrictions
Field names in predicates have the following restrictions:
- You cannot specify a row ID or identity column.
- You cannot specify a field name when you use WHEN with FORMAT BMC, FORMAT UNLOAD, or FORMAT BMCUNLOAD. You must specify a column name.
- For restrictions on the constants that you can specify with a field name in a predicate, see Table 3.
columnName
If you specify a column name, it must be a column of the named table, and the length of the column must be less than or equal to 255. Column names must have corresponding field specifications unless you also specify FORMAT BMC, FORMAT UNLOAD, or FORMAT BMCLOAD. LOADPLUS accepts column names that include DBCS characters.
Restrictions
Column names in predicates have the following restrictions:
- You cannot specify a row ID or identity column.
- For restrictions on the constants that you can specify with a column name in a predicate, see Table 3.
(start:end)
If you specify (start:end), the string defined by (start:end) must be contained entirely in the input record. The length indicated by (start:end), must not be greater than 255 or less than the length of the string. If you do not specify the ending position, LOADPLUS uses the length of the constant for the comparison.
Restrictions
Note the following restrictions when using (start:end):
- If you specify WHEN with FORMAT BMC, FORMAT UNLOAD, FORMAT BMCUNLOAD, or FORMAT CSV, you cannot specify (start:end). For FORMAT BMC, FORMAT UNLOAD, and FORMAT BMCUNLOAD, you must specify a column name. For FORMAT CSV, you must specify a field name or column name.
- For restrictions on the constants that you can specify with (start:end) in a predicate, see the table in constant section.
comparison operators
Use comparison operators in LOADPLUS predicates to indicate how you want LOADPLUS to compare the left and right sides of predicates.
Comparison rules govern the availability of operators and how processing works. Two sets of comparison rules are available, based on the value of the RULES installation option, as described in the following table:
Operators | RULES=STANDARD | RULES=BMC | |
---|---|---|---|
< | Less than |
| X |
<= | Less than or equal |
| X |
= | Equal | X | X |
<> | Not equal | X | X |
¬ = | Not equal | X | X |
>= | Greater than or equal |
| X |
> | Greater than |
| X |
IN | Equal to any | X | X |
NOT IN | Not equal to all | X | X |
constant
The right side of a predicate is a constant. Two different sets of rules apply to constants based on the value of the RULES option that is in effect.
Additional considerations
The following table describes the requirements for constants in predicates. In addition, consider the following information:
Although not prevented or restricted by Db2, you should avoid nonstandard comparisons.
See rules for constants in the IBM Db2 SQL Reference.
- LOADPLUS compares up to 71 bytes of each constant against the field, column, or (start:end) value.
- LOADPLUS does not validate character data or hexadecimal string data against the current CCSID.
- If you specify a list of constants, note the following information:
- You can improve performance by using ascending sequential order. When you specify the list in this order, you save processing time because LOADPLUS does not sort the list.
- When you specify (start:end) with NULLIF or DEFAULTIF, the constants must all be of the same type (for example all character or all hexadecimal) or must all have the same length.
RULES value | Left side of predicate 1 | Constant type | Requirements |
---|---|---|---|
STANDARD | fieldName | Character string | Enclose the string in single quotes. |
Hexadecimal string |
| ||
Other | Other types of constants are not supported. | ||
(start:end) | Character string |
| |
Hexadecimal string |
| ||
Other | Other types of constants are not supported. | ||
columnName | Character string |
| |
Hexadecimal string |
| ||
Other | Other types of constants are not supported. | ||
BMC with fieldName or (start:end) | fieldName | Character string | Enclose the string in single quotes. |
Hexadecimal string |
| ||
Binary string | Enclose the string in single quotes (for example, BX'000C'). | ||
Other | Other types of constants are not supported. | ||
(start:end) | Character string |
| |
Hexadecimal string |
| ||
Other | Other types of constants are not supported. | ||
BMC with columnName | columnName | Integer | The column must be a numeric data type. |
Decimal | The column must be a numeric data type. | ||
Character string |
| ||
Hexadecimal string |
| ||
BMC with columnName (continued) | columnName (continued) | Graphic string | The column must be a graphic data type. LOADPLUS does not support graphic strings with Unicode data, including the hexadecimal graphic string constants UX'xxxx' and GX'xxxx'. |
NULL | The column must be nullable. Note: If used with an inequality operator, NULL always collates higher than all other values. | ||
Binary string |
| ||
Other | Other constant types are not supported. |
1 See the Definition of fieldName and columnName for predicates table for a description of the difference between field name and column name specifications.
Related topic