Contents Index Using Procedures, Triggers, and Batches Benefits of procedures and triggers

ASA SQL User's Guide
  Using Procedures, Triggers, and Batches

Procedure and trigger overview


Procedures and triggers store procedural SQL statements in a database for use by all applications. They 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. SELECT statements can also operate on procedure result sets by including the procedure name in the FROM clause.

Procedures can return result sets to the caller, call other procedures, or fire triggers. For example, a user-defined function is a type of stored procedure that returns a single value to the calling environment. User-defined functions do not modify parameters passed to them, but rather, they broaden the scope of functions available to queries and other SQL statements.

Triggers are associated with specific database tables. They fire automatically whenever someone inserts, updates or deletes rows of the associated table. Triggers can call procedures and fire other triggers, but they have no parameters and cannot be invoked by a CALL statement.

Procedure debugger 

You can debug stored procedures and triggers using the database object debugger. For more information, see Debugging Logic in the Database.

You can profile stored procedures to analyze performance characteristics in Sybase Central. For more information, see Profiling database procedures.


Contents Index Using Procedures, Triggers, and Batches Benefits of procedures and triggers