
The following guidelines provide prerequisites for the acceptance of any stored procedure into the NCSU ACS production environment as of 1 May 1997. Stored procedures submitted for use in the ACS production environment will be reviewed for code efficiency and conformance to these guidelines:
Examples of stored procedures which conform to these guidelines...
Transaction processing is a SQL Server mechanism which ensures data consistency within a specified block of code and automatic data recovery when desired. When using transaction processing within a stored procedure, several SQL statements are treated as if a single operation, preventing other processes from accessing data that may be undergoing change between transaction statements. Transaction processing also allows automatic restoration of data when desired within the transaction; for example, when an error is detected.
A good candidate for transaction processing would be a procedure which needs to modify multiple tables simultaneously without possible interference from other processes. Any procedure which needs its resources protected from outside alteration during processing or requires data recovery in the event of an error should consider using transactions. For more information on transaction processing, its use and limitations, refer to the online Sybase documentation available here at ACS or the Sybase SyBooks WWW Server.
Example of an ACS production stored procedures which uses transaction processing...
Procedures which would benefit from logging (or tracing) features should issue messages which indicate their invocation and completion, as well as general functional progress and error reporting. Even if such procedures are infrequently executed or not regularly monitored, the availability of logging information on demand significantly expedites problem determination. Refer to the example code provided for appropriate logging techniques.
The procedure header will provide information identifying the procedure, its purpose, requirements, behavior, and revision history. The following elements are required:
Click here for a header template.
These instructions will envelope the stored procedure code, preceding its create statement and following its final return execution statement. Using these wrappers will allow us to store local copies all stored procedures and automatically recompile them on a regular basis (this is required to free Sybase system resources which are consumed with each execution of the stored procedure and accumulate over time):
/* ACS Systems maintenance wrapper BEGIN */
use DatabaseName
go
IF EXISTS (SELECT * FROM sysobjects
WHERE name = 'ProcedureName'
AND uid = user_id('dbo')
AND type = 'P')
BEGIN
DROP PROCEDURE ProcedureName
END
go
/* ACS Systems maintenance wrapper END */
...procedure code, concluding with a valid return code...
/* ACS Systems maintenance wrapper BEGIN */ go /* ACS Systems maintenance wrapper END */