Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Partial matches

These examples show how to filter records by comparing against the first N characters of a field.

NOTES:

- When using strncmp(), characters in the comparison string are not included in the comparison when they occur after the specified character count. For example, "strncmp( name, \"Mike\", 1 ) == 0", matches names where the first letter is "M".

- When using strncmp(), you can use a string of any length for partial comparison. Be sure to specify the proper number of characters to include in the comparison. For example, "strncmp( name, \"Mich\", 4 ) == 0", matches names where the first four letters are "Mich", such as "Michael Jordan" and "Michael Schumacher", but not "Muhammad Ali".

- When using strncmp() to compare a UTF-8 string that uses more than one byte per character increase N accordingly. For example, "strncmp( name, \"Pelé\", 5 ) == 0" matches all names in the name field that begin with "Pelé".

In This Section

Partial string match

Partial string non-match

Partial less-than string match

Partial less-than-equal string match

Partial greater-than string match

Partial greater-than-equal string match

Previous Topic

Next Topic

Partial string match

Include records where the first character in a "name" field exactly matches the string "M". Matches include "Michael Jordan", "Michael Schumacher", and "Muhammad Ali".

"strncmp( name, \"M\", 1 ) == 0"

"match( name, \"M*\" ) == 1"

Previous Topic

Next Topic

Partial string non-match

Include records where the first character in a "name" field does not match the string "M". Matches include "Babe Ruth", "Pele", and "Wayne Gretzky", but not "Michael Jordan", "Michael Schumacher", and "Muhammad Ali".

"strncmp( name, \"M\", 1 ) != 0"

"match( name, \"M*\" ) == 0"

Previous Topic

Next Topic

Partial less-than string match

Include records where the first character in a "name" field is less than the string "M". Matches include "Babe Ruth".

"strncmp( name, \"M\", 1 ) < 0"

Previous Topic

Next Topic

Partial less-than-equal string match

Include records where the first character in a "name" field is less than or equal to the string "M". Matches include "Babe Ruth", "Michael Jordan", "Michael Schumacher", and "Muhammad Ali".

"strncmp( name, \"M\", 1 ) <= 0"

Previous Topic

Next Topic

Partial greater-than string match

Include records where the first character in a "name" field is greater than the string "M". Matches include "Pele" and "Wayne Gretzky".

"strncmp( name, \"M\", 1 ) > 0"

Previous Topic

Next Topic

Partial greater-than-equal string match

Include records where the first character in a "name" field is greater than or equal to the string "M". Matches include "Michael Jordan", "Michael Schumacher", "Muhammad Ali", "Pele" and "Wayne Gretzky".

"strncmp( name, \"M\", 1 ) >= 0"

TOCIndex