Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual

2.3.28.3 NdbScanFilter::cmp()

Description.  This method is used to define a comparison between a given value and the value of a column. (This method does not actually execute the comparison, which is done later when performing the scan for which this NdbScanFilter is defined.)

Note

In many cases, where the value to be compared is an integer, you can instead use one of several convenience methods provided by NdbScanFilter for this purpose. See NdbScanFilter Integer Comparison Methods.

Signature. 

int cmp
    (
      BinaryCondition condition,
      int columnId,
      const void* value,
      Uint32 length = 0
    )

Parameters.  This method takes the following parameters:

  • condition: This represents the condition to be tested which compares the value of the column having the column ID columnID with some arbitrary value. The condition is a BinaryCondition value; for permitted values and the relations that they represent, see Section 2.3.28.2, “NdbScanFilter::BinaryCondition”.

    The condition values COND_LIKE or COND_NOTLIKE are used to compare a column value with a string pattern.

  • columnId: This is the column's identifier, which can be obtained using the Column::getColumnNo() method.

  • value: The value to be compared, repesented as a pointer to void.

    When using a COND_LIKE or COND_NOTLIKE comparison condition, the value is treated as a string pattern. This string must not be padded or use a prefix. The string value can include the pattern metacharacters or wildcard characters % and _, which have the meanings shown here:

    Metacharacter Description
    % Matches zero or more characters
    _ Matches exactly one character

    To match against a literal % or _ character, use the backslash (\) as an escape character. To match a literal \ character, use \\.

    Note

    These are the same wildcard characters that are supported by the SQL LIKE and NOT LIKE operators, and are interpreted in the same way. See String Comparison Functions, for more information.

  • length: The length of the value to be compared. The default value is 0. Using 0 for the length has the same effect as comparing to NULL, that is using the isnull() method.

Return value.  This method returns an integer: 0 on success, and -1 on failure.


User Comments
Sign Up Login You must be logged in to post a comment.