DB2 Scalar functions - DIFFERENCE


Volta a página anterior

Volta ao Menu das scalar functions

Volta ao Menu Principal


Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

DIFFERENCE

Returns a value from 0 to 4 representing the difference between the sounds of two strings based on applying the SOUNDEX function to the strings.
A value of 4 is the best possible sound match.

DIFFERENCE(expression ,expression)

The schema is SYSFUN.

expression
An expression that returns a character string or a Boolean value.
In a Unicode database, the expression can also return a graphic string.
If the returned value is not a character string, it is cast to a character string before the function is evaluated.
The character string to be evaluated cannot exceed 4000 bytes.
This function interprets data that is passed to it as if the data were made up of ASCII characters, even if it is encoded in UTF-8.

Result

The result of the function is INTEGER.
The result can be null; if the argument is null, the result is the null value.

Example

The following code:

        VALUES (DIFFERENCE('CONSTRAINT','CONSTANT'),SOUNDEX('CONSTRAINT'),
        SOUNDEX('CONSTANT')),

        (DIFFERENCE('CONSTRAINT','CONTRITE'),SOUNDEX('CONSTRAINT'),
        SOUNDEX('CONTRITE'))
returns the following output:

          1     2    3

-----------  ---- ----
          4  C523 C523
          2  C523 C536

In the first row, the words have the same result from SOUNDEX while in the second row the words have only some similarity.



© Copyright IBM Corp.