Introduction to user-defined functions
Calling user-defined functions
236
If you are using a tool other than DBISQL or Sybase Central, you may need to
change the command delimiter away from the semicolon before entering the
statement.
CREATE FUNCTION
CREATE FUNCTION fullname (firstname CHAR(30),
lastname CHAR(30))
RETURNS CHAR(61)
BEGIN
DECLARE name CHAR(61);
SET name = firstname || ' ' || lastname;
RETURN ( name );
END
For a complete description of the
Server IQ Reference Manual.
The
CREATE FUNCTION
statement. The following are distinctive differences:
PROCEDURE
•
No
,
, or
IN
OUT
INOUT
parameters.
•
The
clause is required to specify the data type being returned.
RETURNS
•
The
statement is required to specify the value being returned.
RETURN
A user-defined function can be used, subject to permissions, in any place that
a built-in non-aggregate function is used.
The following statement in DBISQL returns a full name from two columns
containing a first and last name:
SELECT fullname (emp_fname, emp_lname)
FROM employee;
fullname (emp_fname, emp_lname)
Fran Whitney
Matthew Cobb
Philip Chin
...
The following statement in DBISQL returns a full name from a supplied first
and last name:
CREATE FUNCTION
syntax differs slightly from that of the
keywords are required, as all parameters are IN
syntax, see Adaptive
CREATE