Sybase 12.4.2 Server User Manual


 
229
CHAPTER 6
Using Procedures and Batches
About this chapter
This chapter explains how you create procedures and batches for use with
Adaptive Server IQ.
Procedures store procedural SQL statements in the database for use by all
applications. They enhance the security, efficiency, and standardization of
databases. User-defined functions are one kind of procedure that return a
value to the calling environment for use in queries and other SQL
statements. Batches are sets of SQL statements submitted to the database
server as a group. Many features available in procedures, such as control
statements, are also available in batches.
For many purposes, server-side JDBC provides a more flexible way to
build logic into the database than SQL stored procedures. For information
on JDBC, see Data Access Using JDBC in the Adaptive Server Anywhere
User’s Guide.
Overview of procedures
Procedures store procedural SQL statements in a database for use by all
applications.
Procedures can include control statements that allow repetition (
LOOP
statement) and conditional execution (IF statement and CASE statement)
of SQL statements.
Procedures are invoked with a
CALL statement, and use parameters to
accept values and return values to the calling environment. Procedures can
also return result sets to the caller. Procedures can call other procedures.
User-defined functions are one kind of stored procedure that returns a
single value to the calling environment. User-defined functions do not
modify parameters passed to them. They broaden the scope of functions
available to queries and other SQL statements.