Creating Stored Procedures

System administrators can write stored procedures that can be executed in any database.

The System Administration Guides include discussions about some system procedures that are relevant to system administration. Many system procedures are explained in this manual, in the sections where they are relevant. For detailed reference information about all procedures, see the Reference Manual: Procedures.

Create a stored procedure in sybsystemprocs and assign it a name that begins with “sp_”. The uid of the stored procedure must be 1, the uid of the database owner.

Most system procedures that you create query the system tables. SAP recommends that you do not create stored procedures that modify the system tables.

  1. Use sp_configure to set allow updates to system tables on.
  2. Use create procedure to create the stored procedure.
  3. Use sp_configure to set allow updates to system tables off.
    Warning!   Use caution when you modify system tables. Always test the procedures that modify system tables in development or test databases, rather than in your production database.