Open topic with navigation

TIBCO® Patterns 6.1.2

# Predicate lpar Expressions

The list-type lpar LPAR_LST_PREDICATE contains a predicate expression consisting of one, two, or three elements. Single-element predicates consist solely of a predicate component, which is either a fixed value, a reference to a record field, or another (nested) predicate expression. The following lpars are valid predicate components:

Lpar Id | Lpar contents
LPAR_BOOL_PREDVALUE | Fixed boolean value
LPAR_INT_PREDVALUE | Fixed integer value
LPAR_DBL_PREDVALUE | Fixed double value
LPAR_STR_PREDVALUE | Fixed string value
LPAR_BLK_PREDVALUE | Fixed byte block value
LPAR_BLKARR_PREDVALUE | Array of fixed byte block values
LPAR_INT_PREDFIELD | Reference to a record field by number
LPAR_STR_PREDFIELD | Reference to a record field by name
LPAR_LST_PREDICATE | Another predicate expression

Two-element predicate expressions consist of an LPAR_INT_PREDOP as the first element, and any predicate component as the second element. The value of the LPAR_INT_PREDOP must be one of the following:

LPAR_INT_PREDOP value |
PRED_OP_ABS | Absolute value of int or dbl
PRED_OP_MINUS | Arithmetic inverse of int or dbl
PRED_OP_NOT | Logical inverse of bool
PRED_OP_TOINT | Convert string/block/int/dbl/date/date-time to int
PRED_OP_TOBLK | Convert any type to blk
PRED_OP_TODBL | Convert string/block/int/dbl/date/date-time to dbl
PRED_OP_TODATE | Convert string/block/int/dbl/date/date-time to date
PRED_OP_TODATEEU | as above except it expects European day/month/year format
PRED_OP_TODATET | Convert string/block/int/dbl/date/date-time to date-time
PRED_OP_TODATEEUT | as above except it expects European day/month/year format
PRED_OP_TOKENIZE | Convert a blk or string into a block array of white space separated words.
PRED_OP_ARGS_CREATE | Create an argument list with one element. For information on argument lists, see Predicate Functions and Argument Lists.
PRED_OP_FUNC_IF | Conditional expression. For more details on this predicate function, see Predicate Functions and Argument Lists.
PRED_OP_FUNC_GEOD | Compute the distance between two points. For more details on this predicate function, see Predicate Functions and Argument Lists.
PRED_OP_FUNC_TOSCORE | Normalize a value into a 0.0 to 1.0 score value. For more details on this predicate function, see Predicate Functions and Argument Lists.

Three-element predicate expressions consist of any predicate component as the first element, an LPAR_INT_PREDOP as the second element, and any predicate component as the third element. The value of the LPAR_INT_PREDOP must be one of the following:

LPAR_INT_PREDOP value |
PRED_OP_PLUS | Arithmetic addition of ints, doubles, concatenate strings, blocks
PRED_OP_MINUS | Arithmetic subtraction of ints or doubles
PRED_OP_TIMES | Arithmetic multiplication of ints or doubles
PRED_OP_DIVIDEDBY | Arithmetic division of ints or doubles
PRED_OP_TOTHE | Arithmetic exponentiation of ints or doubles
PRED_OP_AND | Logical and of bools
PRED_OP_OR | Logical or of bools
PRED_OP_EQUALS | Arithmetic or string comparison of ints, dbls, strs, blks, dates
PRED_OP_iEQUALS | Letter case insensitive comparison of strs or blks
PRED_OP_LESSTHAN | Arithmetic or string comparison of ints, dbls, strs, blks, dates
PRED_OP_iLESSTHAN | Letter case insensitive comparison of strs or blks
PRED_OP_LESSTHANOREQ | Arithmetic or string comparison of ints, dbls, strs, blks, dates
PRED_OP_iLESSTHANOREQ | Letter case insensitive comparison of strs or blks
PRED_OP_GREATERTHAN |
PRED_OP_iGREATERTHAN | Letter case insensitive comparison of strs or blks
PRED_OP_GREATERTHANOREQ | Arithmetic or string comparison of ints, dbls, strs, blks, dates
PRED_OP_iGREATERTHANOREQ | Letter case insensitive comparison of strs or blks
PRED_OP_ISIN | Substring match of strings or blks
PRED_OP_iISIN | Letter case insensitive substring match
PRED_OP_SUPERSET | Set comparison of blkarrs
PRED_OP_SUBSET | Set comparison of blkarrs
PRED_OP_TOKENIZE | Split a block or string into words using a specified separator
PRED_OP_ARGS_APPEND | Append a value to an argument list. See Predicate Functions and Argument Lists for more details.
PRED_OP_SW | Check if one string starts with another
PRED_OP_iSW | Check if one string starts with another (case-insensitive)
PRED_OP_EW | Check if one string ends with another
PRED_OP_iEW | Check if one string ends with another (case-insensitive)
PRED_OP_LIKE | Check if one string is “like” another, similar to SQL, takes percent (%) as wildcard matching zero or more characters, and underscore (_) as matching exactly one character.
PRED_OP_iLIKE | As PRED_OP_LIKE, but case-insensitive.
PRED_OP_REGEX_MATCH | Check if one string “matches” another as a regular expression.
PRED_OP_iREGEX_MATCH | As PRED_OP_REGEX_MATCH, but case-insensitive.
PRED_OP_ISBLANK | Check if a value consists only white-space and punctuation.

Each of these operators expects specific value types as arguments; these are validated when the TIBCO Patterns server receives the expression as part of search command. A DVK_ERR_PARAMVAL error is returned if the expression is invalid because the arguments are of an invalid type. But note that many operators accept a number of different argument types. For instance, the PRED_OP_PLUS operator accepts an integer and double values.

To aid the construction of two and three component predicate lpars, two additional DevKit functions are available:

    lpar_t lpar_create_predicate2( int operator, lpar_t predicate );
    lpar_t lpar_create_predicate3( lpar_t left, int operator,
                                   lpar_t right );

To create a predicate to search only those records in a database dated more recently than January 3, 2002, where the date is stored in a field named "`Creation Date"` you could use the following:

    lpar_t predicate;
    predicate = lpar_create_predicate3(
                  lpar_create_predicate2(
                    PRED_OP_TODATE,
                    lpar_create_str(LPAR_STR_PREDFIELD,"Creation Date")),
                  PRED_OP_GREATERTHAN,
                  lpar_create_predicate2(
                    PRED_OP_TODATE,
                    lpar_create_str(LPAR_STR_PREDVALUE,"January 3, 2002")));

The TODATE operator accepts the same date formats as the DATE field type (see The TIBCO Patterns Table) Dates hold only date values, you might specify a time value but it is ignored. If you wish to have resolution down to the second you can use the TODATET operator which keeps both time and date. Dates of the form xx/xx/xx are interpreted in the U.S. style (mm/dd/yy), not the European style (dd/mm/yy) unless the TODATEEU or TODATEEUT operator is used.

The range of valid dates is from 100 AD (years below 100 are interpreted as the last two digits of the current century if less than or equal to the current year, or the last two digits of the previous century if greater than the current year) to 9999 AD.

If the Creation Date field was specified as a LKT_FLD_TYPE_DATE field when the database was created then it is not necessary to convert the field to a date value as it is already stored as a date. The above example then becomes:

    lpar_t predicate;
    predicate = lpar_create_predicate3(
                             lpar_create_str(LPAR_STR_PREDFIELD, "Creation Date"),
                             PRED_OP_GREATERTHAN,
                             lpar_create_predicate2(
                                      PRED_OP_TODATE,
                                         lpar_create_str(LPAR_STR_PREDVALUE,"1/3/2002")));

See The TIBCO Patterns Table for an explanation of field types.

Text comparisons can be performed against the raw string values or using the letter case insensitive operators. These are new with release 4.2. They replace the old TOUPPER and TOLOWER operators. With Unicode support TOUPPER and TOLOWER are both insufficient and ambiguous. The case insensitive comparison operators apply the Unicode standard case folding and normalization rules before comparing the strings. These include stripping diacritic marks and other letter normalization operations. Note that the LESSTHAN, GREATERTHAN operators are based on the Unicode code point values. They DO NOT apply any language specific lexical ordering rules.

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO® Patterns

Copyright © 2010-2025. Cloud Software Group, Inc. All Rights Reserved.