Home > database >  Translate the HashCode method in the Java String into DB2 function, how to implement the code?
Translate the HashCode method in the Java String into DB2 function, how to implement the code?

Time:09-19

A String of hashCode

 public int hashCode () {
Int h=hash;
If (h==0 & amp; & Value. The length & gt; 0 {
Char val []=value;

for (int i=0; I & lt; Value. Length; I++) {
H=31 * h + val [I];
}
Hash=h;
}
Return h;
}

DB2 to create a custom function

 CREATE OR REPLACE FUNCTION HASH_CODE 
RETURN INT
IS
The BEGIN
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The RETURN of 111111
END HASH_CODE;
  •  Tags:  
  • DB2
  • Related