A.1 Sample code for BIT_AND
Example A 1 shows conversion code for MySQLs BIT_AND function.
Example: A 1 User defined function to map BIT_AND
DB2 UDB UDF(User Defined Function) Samples for Migration
2001/08/29
Name of UDF: BIT_AND (N1 Integer, N2 Integer)
Used UDF: None
Description: Returns bit by bit and of both parameters.
Author: TOKUNAGA, Takashi
CREATE FUNCTION BITAND (N1 Integer, N2 Integer)
RETURNS Integer
SPECIFIC BITANDMySQL
LANGUAGE SQL
CONTAINS SQL
NO EXTERNAL ACTION
DETERMINISTIC
RETURN
WITH
Repeat (S, M1, M2, Ans) AS
(Values (0, N1, N2, 0)
Union All
Select S+1, M1/2, M2/2, Ans+MOD(M1,2)*MOD(M2,2)*power(2,S)
From Repeat
Where M1 > 0
AND M2 > 0
AND S < 32
)
SELECT ANS
FROM Repeat
WHERE S = (SELECT MAX(S)
FROM Repeat)
;
Example A 2 shows the results of the BITAND user defined function.
Example: A 2 Results for UDB BITAND
SQL0347W The recursive common table expression "DB2ADMIN.REPEAT"
336
MySQL to DB2 UDB Conversion Guide
footer
Our partners:
PHP: Hypertext Preprocessor Cheap Web Hosting
JSP Web Hosting
Ontario Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Java Hosting
Cheapest Hosting
Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved