Sybase 12.4.2 manual Introduction to user-defined functions, Creating user-defined functions, 235

Models: 12.4.2

1 536
Download 536 pages 20.34 Kb
Page 255
Image 255

CHAPTER 6 Using Procedures and Batches

Employee ID

Salary

243

72995.000

 

 

247

48023.690

 

 

To execute a CALL of a procedure that returns a result set, DBISQL opens a cursor.

The cursor is left open after the CALL in case a second result set is returned. The DBISQL statistics window displays the plan of the SELECT query in the procedure and then displays the line:

Procedure is executing. Use RESUME to continue.

You need to execute the RESUME statement or the DBISQL CLEAR command from the DBISQL Command window before you can alter or drop the procedure.

For more information about using cursors in procedures, see “Using cursors in procedures” on page 251

Introduction to user-defined functions

User-defined functions are a class of procedures that return a single value to the calling environment. This section introduces creating, using, and dropping user-defined functions.

Creating user-defined functions

User-defined functions are created using the CREATE FUNCTION statement. You must have RESOURCE authority in order to create a user-defined function.

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.

You can create the example function fullname by connecting to the sample database from DBISQL as user ID DBA, using password SQL, and typing the statement in the command window.

235

Page 255
Image 255
Sybase 12.4.2 manual Introduction to user-defined functions, Creating user-defined functions, 235