CREAT FUNTION enables users to create a user-defined function with the Sybase CEP Function Language.
The CCL Create Function statement creates a user-defined function (UDF). The function definition is valid only inside the query module in which it is defined, or in any other query module which imports it by using the CCL Import statement. In all other ways, CCL UDFs can be used according to the same rules, and subject to the same restrictions, as predefined Sybase CEP functions.
CCL UDF definitions are valid only inside the current query module (.ccl file). UDF definitions in other files must be imported with the Import statement.
Import Statement
Sybase CEP Function Language
The following example shows an EARTHDISTANCE() function definition that calculates the distance between two geographical points:
CREATE FUNCTION EARTHDISTANCE( Latitude1 FLOAT, Longitude1 FLOAT, Latitude2 FLOAT, Longitude2 FLOAT) RETURNS FLOAT; RETURN (180/pi()) * 60 * 1.1515 * ACOS( SIN(Latitude1*pi()/180) * SIN(Latitude2*pi()/180) + COS(Latitude1*pi()/180) * COS(Latitude2*pi()/180) * COS((Longitude1 - Longitude2)*pi()/180) ); END FUNCTION;