LANGUAGE SQL
 SPECIFIC LEASTOracle10
 DETERMINISTIC
 CONTAINS SQL
 NO EXTERNAL ACTION
 RETURN 
LEAST(LEAST(P1,P2,P3,P4,P5),LEAST(P6,P7,P8,P9,P10))
;
Example A 20 shows the results of UDF's LEAST.
Example: A 20   Results of UDFs mapping LEAST
SELECT least( HARRY , HARRIOT , HAROLD ) FROM sysibm.sysdummy1;
                                                   
1                                                                                      
                                                                           
            
HAROLD                                                                                 
    1 record(s) selected
A.6  Sample code for BIT_COUNT
Example A 21 is a UDF example emulating the behavior of MySQL's 
BIT_COUNT function. It returns the number of set bits in the parameter (the 
number of 
1
 in the binary value of the parameter) assuming that the parameter is 
a 32 bit 
INTEGER
.
Example: A 21   User defined function to map BIT_COUNT
CREATE FUNCTION BIT_CNT (N1 Integer)
 RETURNS Integer
 SPECIFIC BITCNTMySQL
 LANGUAGE SQL
 CONTAINS SQL
 NO EXTERNAL ACTION
 DETERMINISTIC
 RETURN
WITH
 Repeat (S, M1, Ans) AS
(Values (0, N1, 0)
Union All
Select S+1, M1/2, Ans+MOD(M1,2)
  From Repeat
 Appendix A. Sample code for user defined functions 
359






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

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