home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win.exe / DATA1.CAB / Examples / examples / tests / udf_test < prev    next >
Text File  |  2000-11-22  |  1KB  |  31 lines

  1. #
  2. # For this script to work, you need to compile and install the
  3. # udf_example script !
  4. #
  5.  
  6. CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
  7. CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
  8. CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
  9. CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
  10. CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
  11. CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "udf_example.so";
  12.  
  13. select metaphon("hello"); 
  14. select myfunc_double("hello","world");
  15. select myfunc_int(1,2,3),myfunc_int("1","11","111");
  16. select lookup("localhost");
  17. select reverse_lookup("127.0.0.1");
  18.  
  19. create temporary table t1 (a int,b double);
  20. insert into t1 values (1,5),(1,4),(2,8),(3,9),(4,11);
  21. select avgcost(a,b) from t1;
  22. select avgcost(a,b) from t1 group by a;
  23. drop table t1;
  24.  
  25. DROP FUNCTION metaphon;
  26. DROP FUNCTION myfunc_double;
  27. DROP FUNCTION myfunc_int;
  28. DROP FUNCTION lookup;
  29. DROP FUNCTION reverse_lookup;
  30. DROP FUNCTION avgcost;
  31.