Introduction to 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
CREATE FUNCTION
statement.
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
CREATE FUNCTION
syntax, see Adaptive
Server IQ Reference Manual.
The
CREATE FUNCTION
syntax differs slightly from that of the
CREATE
PROCEDURE
statement. The following are distinctive differences:
•
No
IN
,
OUT
, or
INOUT
keywords are required, as all parameters are IN
parameters.
•
The
RETURNS
clause is required to specify the data type being returned.
•
The
RETURN
statement is required to specify the value being returned.
Calling user-defined functions
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;
The following statement in DBISQL returns a full name from a supplied first
and last name:
fullname (emp_fname, emp_lname)
Fran Whitney
Matthew Cobb
Philip Chin
...
Summary of Contents for Adaptive Server IQ 12.4.2
Page 1: ...Administration and Performance Guide Adaptive Server IQ 12 4 2 ...
Page 16: ...xvi ...
Page 20: ...Related documents xx ...
Page 40: ...Compatibility with earlier versions 20 ...
Page 118: ...Troubleshooting startup shutdown and connections 98 ...
Page 248: ...Importing data by replication 228 ...
Page 306: ...Integrity rules in the system tables 286 ...
Page 334: ...Cursors in transactions 314 ...
Page 396: ...Users and permissions in the system tables 376 ...
Page 438: ...Determining your data backup and recovery strategy 418 ...
Page 484: ...Network performance 464 ...
Page 500: ...System utilities to monitor CPU use 480 ...
Page 514: ...Characteristics of Open Client and jConnect connections 494 ...
Page 536: ...Index 516 ...