Creating an ASE Stored Procedure

A stored procedure is a group of SQL statements and optional control-of-flow (if, else, while statements, and so on) that form a logical unit and perform a particular task. Stored procedures encapsulate a set of operations or queries to execute on a database server.

Prerequisites 

To create an Adaptive Server Enterprise stored procedure skeleton using Database Development, establish an Adaptive Server Enterprise connection profile.

  1. In the Databases folder in Enterprise Explorer, under the database connection profile, expand the tree for a database, expand the Schemas folder and then the tree for the appropriate schema owner.
  2. Right-click the Stored Procedures folder, and choose New > Stored Procedure.
  3. Enter the Name for the stored procedure.

    Do not use spaces in Adaptive Server Enterprise procedural object names. Select Recompile to recompile the stored procedure every time it is invoked.

  4. (Optional) Enter a description in the Comments field.
  5. Click Next to add parameters.
  6. Enter a parameter Name.
  7. Select the Datatype.
  8. Select the IN/OUT option.
  9. (Optional) Specify the default value for the parameter you are defining.
  10. Click Next to declare variables.
  11. Enter the Name for any local variables that you want to declare.
  12. Select the Datatype.
  13. Click Next and specify save and execution properties.
    Field Description
    Generate Script Generate a SQL file for the object.
    Enter or Select the Parent Folder Specify an existing project or create a new project in which to save the SQL file.
    File Name Enter the file name in which to store the SQL code.
    Execute Immediately Execute the SQL code immediately. If you do not select this option, you must complete execution of the SQL file later to create the object.
    Open in Editor After Creation Create the object and open it in its associated editor.
  14. Click Finish to create the stored procedure.
Related concepts
Stored Procedures
Related tasks
Creating a SQL Anywhere or Sybase IQ Stored Procedure
Editing a Stored Procedure
Dropping a Stored Procedure
Renaming a Stored Procedure
Opening a Referenced Database Object
Creating a Database Service from a Stored Procedure

For product-related issues, contact Sybase Technical Support at 1-800-8SYBASE. Send your feedback on this help topic directly to Sybase Technical Publications: pubs@sybase.com