Sybase 12.4.2 User Manual

Page of 536
Introduction to procedures
232
 
The body of a procedure is a compound statement. The compound statement 
starts with a 
BEGIN 
statement and concludes with an 
END 
statement. In the case 
of 
new_dept
, the compound statement is a single INSERT bracketed by BEGIN 
and END statements.
For more information, see “Using compound statements” on page 240
Parameters to procedures are marked as one of IN, OUT, or INOUT. All 
parameters to the 
new_dept
 procedure are IN parameters, as they are not 
changed by the procedure.
Calling procedures
A procedure is invoked with a CALL statement. Procedures can be called by 
an application program, or they can be called by other procedures.
For more information, see Adaptive Server IQ Reference Manual.
The following statement calls the 
new_dept
 procedure to insert an Eastern 
Sales department:
CALL new_dept( 210, ’Eastern Sales’, 902 );
After this call, you may wish to check the department table to see that the new 
department has been added.
The 
new_dept
 procedure can be called by all users who have been granted 
EXECUTE permission for the procedure, even if they have no permissions on 
the 
department
 table.
Dropping procedures
Once a procedure is created, it remains in the database until it is explicitly 
removed. Only the owner of the procedure or a user with DBA authority can 
drop the procedure from the database.
The following statement removes the procedure 
new_dept
 from the database:
DROP PROCEDURE new_dept