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 are used to encapsulate a set of operations or queries to execute on a database server. To create an Adaptive Server Enterprise stored procedure skeleton using Database Development tooling, you must have established an Adaptive Server Enterprise connection profile

  1. In Database Explorer under an Adaptive Server Enterprise connection profile, right-click the Procedures & Functions folder.

  2. Select New|Procedure to invoke the Stored Procedure wizard.

    The Create Stored Procedure Skeleton page appears.

  3. Enter the stored procedure name in the Name field and optional description of the stored procedure that you are creating in the Comments field. Do not use spaces in Adaptive Server Enterprise procedural object names. Select the Recompile check box if you want the stored procedure recompiled every time it is invoked.

    The Preview field displays the syntax generated so far.

  4. Click Finish if you have no parameters or variables to declare. Click Next to add parameters.

    The Provide Optional Parameters Declaration page appears.

  5. Enter a parameter name in the Name column.

  6. Click the Datatype column to select a datatype from the drop-down list.

  7. Click the IN/OUT column to select the available input or output option.

  8. (Optional) Specify the default value for the parameter you are defining.

  9. If you have variables to declare, click Next

    The Provide Optional Variables Declaration page appears.

    Alternatively, click Finish if you have no variables to declare.

  10. In the Name column, enter any local variable names that you want to declare.

  11. Click the Datatype column to select a datatype from the drop-down list.

  12. Click Finish. A stored procedure skeleton is opened in SQL Editor.

Developing Procedural Objects

Running a Procedural Object

Saving a Procedural Object Definition to a Database

Creating an ASE Connection Profile

Learn More About Procedural Objects

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com