4. Elements of OpenSQL Statements : Functions : Scalar Functions : Hash Function
 
Share this page                  
Hash Function
This function is used to generate a four-byte numeric value from expressions of all data types except long data types. Note that the implicit size for the expression can affect the result. For example:
select hash(1), hash(int1(1)), hash(int2(1)), hash(int4(1))\g
returns the following single row:
Col1
Col2
Col3
Col4
-920527466
1526341860
-920527466
-1447292811
Note:  Since the constant 1 is implicitly a short integer, only the return values for Hash(1) and Hash(int2(1)) match. For the remaining columns, the difference in the number of bytes holding the integer leads to a different hash value. Also note that the generated hash value is not guaranteed unique, even if the input values are unique. The hash function is not supported for Enterprise Access products.