You use the CREATE FUNCTION statement to create user-defined functions. You must have RESOURCE authority to execute this statement.
The following simple example creates a function that concatenates two strings, together with a space, to form a full name from a first name and a last name.
CREATE FUNCTION FullName( FirstName CHAR(30), LastName CHAR(30) ) RETURNS CHAR(61) BEGIN DECLARE name CHAR(61); SET name = FirstName || ' ' || LastName; RETURN ( name ); END;
The CREATE FUNCTION syntax differs slightly from that of the CREATE PROCEDURE statement. The following are distinctive differences:
You can also create user-defined functions from Sybase Central.
To create a user-defined function (Sybase Central)
Connect to the database as a user with DBA or Resource authority.
In the left pane, click Procedures & Functions.
Choose File » New » Function.
Follow the instructions in the Create Function Wizard.
In the right pane, click the SQL tab to complete the procedure code.
The new function appears in Procedures & Functions.
|Send feedback about this page via email or DocCommentXchange||Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0|