Sybase 12.4.2 Server User Manual


 
CHAPTER 6 Using Procedures and Batches
231
Control who has permission to use procedures
This section discusses each of these aspects of using procedures, and also
describes some of the different uses of procedures.
Creating procedures
Procedures are created using the CREATE PROCEDURE statement. You must
have RESOURCE authority in order to create a procedure.
Where you enter the statement depends on the tool you are using:
You can create the example procedure
new_dept by connecting to the
sample database from DBISQL as user ID DBA, using password SQL, and
typing the statement in the command window.
You can create the example procedure by connecting to the sample
database from Sybase Central, opening the Procedures folder, and clicking
Add Procedure/Function Wizard. The Wizard walks you through the
process. Alternatively, click Add Procedure/Function Template, which
places you immediately in the last window of the Wizard, the Procedure
window, in which you enter the code for the procedure.
If you are using a tool other than DBISQL or Sybase Central, follow the
instructions for your tool. You may need to change the command delimiter
away from the semicolon before entering the
CREATE PROCEDURE
statement.
The following simple example creates a procedure that carries out an INSERT
into the department table of the sample database, creating a new department.
CREATE PROCEDURE new_dept ( IN id INT,
IN name CHAR(35),
IN head_id INT )
BEGIN
INSERT
INTO DBA.department ( dept_id,
dept_name,
dept_head_id )
VALUES ( id, name, head_id );
END
For a complete description of the CREATE PROCEDURE syntax, see Adaptive
Server IQ Reference Manual.