home *** CD-ROM | disk | FTP | other *** search
/ Freelog 42 / Freelog042.iso / Alu / Ancestrologie / Sources / InterBase_WI-V6.0.1-server.ZIP / examples / udf / ib_udf.sql next >
Text File  |  2001-01-05  |  16KB  |  602 lines

  1. /*
  2.  * The contents of this file are subject to the Interbase Public
  3.  * License Version 1.0 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy
  5.  * of the License at http://www.Inprise.com/IPL.html
  6.  *
  7.  * Software distributed under the License is distributed on an
  8.  * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
  9.  * or implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  *
  12.  * The Original Code was created by Inprise Corporation
  13.  * and its predecessors. Portions created by Inprise Corporation are
  14.  *
  15.  * Copyright (C) 2000 Inprise Corporation
  16.  * All Rights Reserved.
  17.  * Contributor(s): ______________________________________.
  18.  */
  19. /*****************************************
  20.  *
  21.  *    a b s
  22.  *
  23.  *****************************************
  24.  *
  25.  * Functional description:
  26.  *     Returns the absolute value of a 
  27.  *     number.  
  28.  *
  29.  *****************************************/
  30. DECLARE EXTERNAL FUNCTION abs 
  31.     DOUBLE PRECISION
  32.     RETURNS DOUBLE PRECISION BY VALUE
  33.     ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';
  34.  
  35. /*****************************************
  36.  *
  37.  *    a c o s
  38.  *
  39.  *****************************************
  40.  *
  41.  * Functional description:
  42.  *    Returns the arccosine of a number 
  43.  *    between -1 and 1, if the number is
  44.  *    out of bounds it returns NaN, as handled
  45.  *    by the _matherr routine.
  46.  *
  47.  *****************************************/
  48. DECLARE EXTERNAL FUNCTION acos 
  49.     DOUBLE PRECISION
  50.     RETURNS DOUBLE PRECISION BY VALUE
  51.     ENTRY_POINT 'IB_UDF_acos' MODULE_NAME 'ib_udf';
  52.  
  53. /*****************************************
  54.  *
  55.  *    a s c i i _ c h a r
  56.  *
  57.  *****************************************
  58.  *
  59.  * Functional description:
  60.  *    Returns the ASCII character corresponding
  61.  *    with the value passed in.
  62.  *
  63.  *****************************************/
  64. DECLARE EXTERNAL FUNCTION ascii_char
  65.     INTEGER
  66.     RETURNS CHAR(1) FREE_IT
  67.     ENTRY_POINT 'IB_UDF_ascii_char' MODULE_NAME 'ib_udf';
  68.  
  69. /*****************************************
  70.  *
  71.  *    a s c i i _ v a l
  72.  *
  73.  *****************************************
  74.  *
  75.  * Functional description:
  76.  *    Returns the ascii value of the character
  77.  *     passed in.
  78.  *
  79.  *****************************************/
  80. DECLARE EXTERNAL FUNCTION ascii_val
  81.     CHAR(1)
  82.     RETURNS INTEGER BY VALUE
  83.     ENTRY_POINT 'IB_UDF_ascii_val' MODULE_NAME 'ib_udf';
  84.  
  85. /*****************************************
  86.  *
  87.  *    a s i n
  88.  *
  89.  *****************************************
  90.  *
  91.  * Functional description:
  92.  *    Returns the arcsin of a number between
  93.  *    -1 and 1, if the number is out of
  94.  *    range NaN is returned.
  95.  *
  96.  *****************************************/
  97. DECLARE EXTERNAL FUNCTION asin 
  98.     DOUBLE PRECISION
  99.     RETURNS DOUBLE PRECISION BY VALUE
  100.     ENTRY_POINT 'IB_UDF_asin' MODULE_NAME 'ib_udf';
  101.  
  102. /*****************************************
  103.  *
  104.  *    a t a n
  105.  *
  106.  *****************************************
  107.  *
  108.  * Functional description:
  109.  *    Returns the arctangent of a number.
  110.  *    
  111.  *
  112.  *****************************************/
  113. DECLARE EXTERNAL FUNCTION atan 
  114.     DOUBLE PRECISION
  115.     RETURNS DOUBLE PRECISION BY VALUE
  116.     ENTRY_POINT 'IB_UDF_atan' MODULE_NAME 'ib_udf';
  117.  
  118. /*****************************************
  119.  *
  120.  *    a t a n 2
  121.  *
  122.  *****************************************
  123.  *
  124.  * Functional description:
  125.  *     Returns the arctangent of the
  126.  *    first param / the second param.
  127.  *
  128.  *****************************************/
  129. DECLARE EXTERNAL FUNCTION atan2 
  130.     DOUBLE PRECISION, DOUBLE PRECISION
  131.     RETURNS DOUBLE PRECISION BY VALUE
  132.     ENTRY_POINT 'IB_UDF_atan2' MODULE_NAME 'ib_udf';
  133.  
  134. /*****************************************
  135.  *
  136.  *    b i n _ a n d
  137.  *
  138.  *****************************************
  139.  *
  140.  * Functional description:
  141.  *    Returns the result of a binary AND 
  142.  *    operation performed on the two numbers.
  143.  *
  144.  *****************************************/
  145. DECLARE EXTERNAL FUNCTION bin_and 
  146.     INTEGER, INTEGER
  147.     RETURNS INTEGER BY VALUE
  148.     ENTRY_POINT 'IB_UDF_bin_and' MODULE_NAME 'ib_udf';
  149.  
  150. /*****************************************
  151.  *
  152.  *    b i n _ o r
  153.  *
  154.  *****************************************
  155.  *
  156.  * Functional description:
  157.  *    Returns the result of a binary OR 
  158.  *    operation performed on the two numbers.
  159.  *
  160.  *****************************************/
  161. DECLARE EXTERNAL FUNCTION bin_or 
  162.     INTEGER, INTEGER
  163.     RETURNS INTEGER BY VALUE
  164.     ENTRY_POINT 'IB_UDF_bin_or' MODULE_NAME 'ib_udf';
  165.  
  166. /*****************************************
  167.  *
  168.  *    b i n _ x o r
  169.  *
  170.  *****************************************
  171.  *
  172.  * Functional description:
  173.  *    Returns the result of a binary XOR 
  174.  *    operation performed on the two numbers.
  175.  *
  176.  *****************************************/
  177. DECLARE EXTERNAL FUNCTION bin_xor 
  178.     INTEGER, INTEGER
  179.     RETURNS INTEGER BY VALUE
  180.     ENTRY_POINT 'IB_UDF_bin_xor' MODULE_NAME 'ib_udf';
  181.  
  182. /*****************************************
  183.  *
  184.  *    c e i l i n g
  185.  *
  186.  *****************************************
  187.  *
  188.  * Functional description:
  189.  *    Returns a double value representing 
  190.  *    the smallest integer that is greater 
  191.  *    than or equal to the input value.
  192.  *
  193.  *****************************************/
  194. DECLARE EXTERNAL FUNCTION ceiling 
  195.     DOUBLE PRECISION
  196.     RETURNS DOUBLE PRECISION BY VALUE
  197.     ENTRY_POINT 'IB_UDF_ceiling' MODULE_NAME 'ib_udf';
  198.  
  199. /*****************************************
  200.  *
  201.  *    c o s
  202.  *
  203.  *****************************************
  204.  *
  205.  * Functional description:
  206.  *    The cos function returns the cosine 
  207.  *    of x. If x is greater than or equal 
  208.  *    to 263, or less than or equal to -263, 
  209.  *    a loss of significance in the result 
  210.  *    of a call to cos occurs, in which case 
  211.  *    the function generates a _TLOSS error 
  212.  *    and returns an indefinite (same as a 
  213.  *    quiet NaN).
  214.  *
  215.  *****************************************/
  216. DECLARE EXTERNAL FUNCTION cos 
  217.     DOUBLE PRECISION
  218.     RETURNS DOUBLE PRECISION BY VALUE
  219.     ENTRY_POINT 'IB_UDF_cos' MODULE_NAME 'ib_udf';
  220.  
  221. /*****************************************
  222.  *
  223.  *    c o s h
  224.  *
  225.  *****************************************
  226.  *
  227.  * Functional description:
  228.  *    The cosh function returns the hyperbolic cosine 
  229.  *    of x. If x is greater than or equal 
  230.  *    to 263, or less than or equal to -263, 
  231.  *    a loss of significance in the result 
  232.  *    of a call to cos occurs, in which case 
  233.  *    the function generates a _TLOSS error 
  234.  *    and returns an indefinite (same as a 
  235.  *    quiet NaN).
  236.  *
  237.  *****************************************/
  238. DECLARE EXTERNAL FUNCTION cosh 
  239.     DOUBLE PRECISION
  240.     RETURNS DOUBLE PRECISION BY VALUE
  241.     ENTRY_POINT 'IB_UDF_cosh' MODULE_NAME 'ib_udf';
  242.  
  243. /*****************************************
  244.  *
  245.  *    c o t
  246.  *
  247.  *****************************************
  248.  *
  249.  * Functional description:
  250.  *    Returns 1 over the tangent of the
  251.  *    input parameter.
  252.  *
  253.  *****************************************/
  254. DECLARE EXTERNAL FUNCTION cot 
  255.     DOUBLE PRECISION
  256.     RETURNS DOUBLE PRECISION BY VALUE
  257.     ENTRY_POINT 'IB_UDF_cot' MODULE_NAME 'ib_udf';
  258.  
  259. /*****************************************
  260.  *
  261.  *    d i v
  262.  *
  263.  *****************************************
  264.  *
  265.  * Functional description:
  266.  *    Returns the quotient part of the division
  267.  *    of the two input parameters.
  268.  *
  269.  *****************************************/
  270. DECLARE EXTERNAL FUNCTION div 
  271.     INTEGER, INTEGER
  272.     RETURNS DOUBLE PRECISION BY VALUE
  273.     ENTRY_POINT 'IB_UDF_div' MODULE_NAME 'ib_udf';
  274.  
  275. /*****************************************
  276.  *
  277.  *    f l o o r
  278.  *
  279.  *****************************************
  280.  *
  281.  * Functional description:
  282.  *     Returns a floating-point value 
  283.  *     representing the largest integer that 
  284.  *    is less than or equal to x    
  285.  *
  286.  *****************************************/
  287. DECLARE EXTERNAL FUNCTION floor 
  288.     DOUBLE PRECISION
  289.     RETURNS DOUBLE PRECISION BY VALUE
  290.     ENTRY_POINT 'IB_UDF_floor' MODULE_NAME 'ib_udf';
  291.  
  292. /*****************************************
  293.  *
  294.  *    l n
  295.  *
  296.  *****************************************
  297.  *
  298.  * Functional description:
  299.  *    Returns the natural log of a number.
  300.  *
  301.  *****************************************/
  302. DECLARE EXTERNAL FUNCTION ln 
  303.     DOUBLE PRECISION
  304.     RETURNS DOUBLE PRECISION BY VALUE
  305.     ENTRY_POINT 'IB_UDF_ln' MODULE_NAME 'ib_udf';
  306.  
  307. /*****************************************
  308.  *
  309.  *    l o g
  310.  *
  311.  *****************************************
  312.  *
  313.  * Functional description:
  314.  *    log (x,y) returns the logarithm 
  315.  *    base x of y.
  316.  *
  317.  *****************************************/
  318. DECLARE EXTERNAL FUNCTION log 
  319.     DOUBLE PRECISION, DOUBLE PRECISION
  320.     RETURNS DOUBLE PRECISION BY VALUE
  321.     ENTRY_POINT 'IB_UDF_log' MODULE_NAME 'ib_udf';
  322.  
  323. /*****************************************
  324.  *
  325.  *    l o g 1 0
  326.  *
  327.  *****************************************
  328.  *
  329.  * Functional description:
  330.  *    Returns the logarithm base 10 of the
  331.  *    input parameter.
  332.  *
  333.  *****************************************/
  334. DECLARE EXTERNAL FUNCTION log10 
  335.     DOUBLE PRECISION
  336.     RETURNS DOUBLE PRECISION BY VALUE
  337.     ENTRY_POINT 'IB_UDF_log10' MODULE_NAME 'ib_udf';
  338.  
  339. /*****************************************
  340.  *
  341.  *    l o w e r
  342.  *
  343.  *****************************************
  344.  *
  345.  * Functional description:
  346.  *    Returns the input string into lower 
  347.  *    case characters.  Note: This function
  348.  *    will not work with international and 
  349.  *    non-ascii characters.
  350.  *    Note: This function is NOT limited to
  351.  *    receiving and returning only 80 characters,
  352.  *    rather, it can use as long as 32767 
  353.  *     characters which is the limit on an 
  354.  *    INTERBASE character string.
  355.  *
  356.  *****************************************/
  357. DECLARE EXTERNAL FUNCTION lower 
  358.     CSTRING(80)
  359.     RETURNS CSTRING(80) FREE_IT
  360.     ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf';
  361.  
  362. /*****************************************
  363.  *
  364.  *    l t r i m
  365.  *
  366.  *****************************************
  367.  *
  368.  * Functional description:
  369.  *    Removes leading spaces from the input
  370.  *    string.
  371.  *    Note: This function is NOT limited to
  372.  *    receiving and returning only 80 characters,
  373.  *    rather, it can use as long as 32767 
  374.  *     characters which is the limit on an 
  375.  *    INTERBASE character string.
  376.  *
  377.  *****************************************/
  378. DECLARE EXTERNAL FUNCTION ltrim 
  379.     CSTRING(80)
  380.     RETURNS CSTRING(80) FREE_IT
  381.     ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
  382.  
  383. /*****************************************
  384.  *
  385.  *    m o d
  386.  *
  387.  *****************************************
  388.  *
  389.  * Functional description:
  390.  *    Returns the remainder part of the 
  391.  *    division of the two input parameters.
  392.  *
  393.  *****************************************/
  394. DECLARE EXTERNAL FUNCTION mod 
  395.     INTEGER, INTEGER
  396.     RETURNS DOUBLE PRECISION BY VALUE
  397.     ENTRY_POINT 'IB_UDF_mod' MODULE_NAME 'ib_udf';
  398.  
  399. /*****************************************
  400.  *
  401.  *    p i
  402.  *
  403.  *****************************************
  404.  *
  405.  * Functional description:
  406.  *    Returns the value of pi = 3.1459...
  407.  *
  408.  *****************************************/
  409. DECLARE EXTERNAL FUNCTION pi 
  410.     RETURNS DOUBLE PRECISION BY VALUE
  411.     ENTRY_POINT 'IB_UDF_pi' MODULE_NAME 'ib_udf';
  412.  
  413. /*****************************************
  414.  *
  415.  *    r a n d
  416.  *
  417.  *****************************************
  418.  *
  419.  * Functional description:
  420.  *    Returns a random number between 0 
  421.  *    and 1.  Note the random number
  422.  *    generator is seeded using the current 
  423.  *    time.
  424.  *
  425.  *****************************************/
  426. DECLARE EXTERNAL FUNCTION rand 
  427.     RETURNS DOUBLE PRECISION BY VALUE
  428.     ENTRY_POINT 'IB_UDF_rand' MODULE_NAME 'ib_udf';
  429.  
  430. /*****************************************
  431.  *
  432.  *    r t r i m
  433.  *
  434.  *****************************************
  435.  *
  436.  * Functional description:
  437.  *    Removes trailing spaces from the input
  438.  *    string.
  439.  *    Note: This function is NOT limited to
  440.  *    receiving and returning only 80 characters,
  441.  *    rather, it can use as long as 32767 
  442.  *     characters which is the limit on an 
  443.  *    INTERBASE character string.
  444.  *
  445.  *****************************************/
  446. DECLARE EXTERNAL FUNCTION rtrim 
  447.     CSTRING(80)
  448.     RETURNS CSTRING(80) FREE_IT
  449.     ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';
  450.  
  451. /*****************************************
  452.  *
  453.  *    s i g n
  454.  *
  455.  *****************************************
  456.  *
  457.  * Functional description:
  458.  *    Returns 1, 0, or -1 depending on whether
  459.  *     the input value is positive, zero or 
  460.  *    negative, respectively.
  461.  *
  462.  *****************************************/
  463. DECLARE EXTERNAL FUNCTION sign 
  464.     DOUBLE PRECISION
  465.     RETURNS INTEGER BY VALUE
  466.     ENTRY_POINT 'IB_UDF_sign' MODULE_NAME 'ib_udf';
  467.  
  468. /*****************************************
  469.  *
  470.  *    s i n
  471.  *
  472.  *****************************************
  473.  *
  474.  * Functional description:
  475.  *    Returns the sine of x. If x is greater 
  476.  *    than or equal to 263, or less than or 
  477.  *    equal to -263, a loss of significance 
  478.  *    in the result occurs, in which case the 
  479.  *    function generates a _TLOSS error and 
  480.  *    returns an indefinite (same as a quiet NaN).
  481.  *
  482.  *****************************************/
  483. DECLARE EXTERNAL FUNCTION sin 
  484.     DOUBLE PRECISION
  485.     RETURNS DOUBLE PRECISION BY VALUE
  486.     ENTRY_POINT 'IB_UDF_sin' MODULE_NAME 'ib_udf';
  487.  
  488. /*****************************************
  489.  *
  490.  *    s i n h
  491.  *
  492.  *****************************************
  493.  *
  494.  * Functional description:
  495.  *    Returns the hyperbolic sine of x. If x is greater 
  496.  *    than or equal to 263, or less than or 
  497.  *    equal to -263, a loss of significance 
  498.  *    in the result occurs, in which case the 
  499.  *    function generates a _TLOSS error and 
  500.  *    returns an indefinite (same as a quiet NaN).
  501.  *
  502.  *****************************************/
  503. DECLARE EXTERNAL FUNCTION sinh 
  504.     DOUBLE PRECISION
  505.     RETURNS DOUBLE PRECISION BY VALUE
  506.     ENTRY_POINT 'IB_UDF_sinh' MODULE_NAME 'ib_udf';
  507.  
  508. /*****************************************
  509.  *
  510.  *    s q r t
  511.  *
  512.  *****************************************
  513.  *
  514.  * Functional description:
  515.  *    Returns the square root of a number.
  516.  *
  517.  *****************************************/
  518. DECLARE EXTERNAL FUNCTION sqrt 
  519.     DOUBLE PRECISION
  520.     RETURNS DOUBLE PRECISION BY VALUE
  521.     ENTRY_POINT 'IB_UDF_sqrt' MODULE_NAME 'ib_udf';
  522.  
  523. /*****************************************
  524.  *
  525.  *    s u b s t r
  526.  *
  527.  *****************************************
  528.  *
  529.  * Functional description:
  530.  *    substr(s,m,n) returns the substring 
  531.  *    of s which starts at position m and
  532.  *    ending at position n.
  533.  *    Note: This function is NOT limited to
  534.  *    receiving and returning only 80 characters,
  535.  *    rather, it can use as long as 32767 
  536.  *     characters which is the limit on an 
  537.  *    INTERBASE character string.
  538.  *
  539.  *****************************************/
  540. DECLARE EXTERNAL FUNCTION substr 
  541.     CSTRING(80), SMALLINT, SMALLINT
  542.     RETURNS CSTRING(80) FREE_IT
  543.     ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf';
  544.  
  545. /*****************************************
  546.  *
  547.  *    s t r l e n
  548.  *
  549.  *****************************************
  550.  *
  551.  * Functional description:
  552.  *    Returns the length of a given string.
  553.  *
  554.  *****************************************/
  555. DECLARE EXTERNAL FUNCTION strlen 
  556.     CSTRING(32767)
  557.     RETURNS INTEGER BY VALUE
  558.     ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf';
  559.  
  560. /*****************************************
  561.  *
  562.  *    t a n
  563.  *
  564.  *****************************************
  565.  *
  566.  * Functional description:
  567.  *     Returns the tangent of x. If x is 
  568.  *    greater than or equal to 263, or less 
  569.  *    than or equal to -263, a loss of 
  570.  *    significance in the result occurs, in 
  571.  *    which case the function generates a 
  572.  *    _TLOSS error and returns an indefinite 
  573.  *    (same as a quiet NaN).
  574.  *
  575.  *****************************************/
  576. DECLARE EXTERNAL FUNCTION tan 
  577.     DOUBLE PRECISION
  578.     RETURNS DOUBLE PRECISION BY VALUE
  579.     ENTRY_POINT 'IB_UDF_tan' MODULE_NAME 'ib_udf';
  580.  
  581. /*****************************************
  582.  *
  583.  *    t a n h
  584.  *
  585.  *****************************************
  586.  *
  587.  * Functional description:
  588.  *     Returns the tangent of x. If x is 
  589.  *    greater than or equal to 263, or less 
  590.  *    than or equal to -263, a loss of 
  591.  *    significance in the result occurs, in 
  592.  *    which case the function generates a 
  593.  *    _TLOSS error and returns an indefinite 
  594.  *    (same as a quiet NaN).
  595.  *    
  596.  *****************************************/
  597. DECLARE EXTERNAL FUNCTION tanh 
  598.     DOUBLE PRECISION
  599.     RETURNS DOUBLE PRECISION BY VALUE
  600.     ENTRY_POINT 'IB_UDF_tanh' MODULE_NAME 'ib_udf';
  601.  
  602.