Viewing stored procedure code with Sybase Central

There are several stored procedures included in the sample database. The following steps explain how to view and edit stored procedures.

StepsViewing and editing procedures

  1. Select the Procedures & Functions folder from the sample database in the left panel. You may have to expand the database container to do this.

  2. Right-click the procedure in the right panel; for example sp_customer_list.

  3. In the submenu, click Edit in New Window (Ctrl+E).

    The Sybase Central code editor appears, displaying the text of the procedure.

    ALTER procedure
    "DBA"."sp_customer_list"()
    result(id integer,company_name char(35))
    begin
    select id,company_name from customer
    end
    

    Menu options and toolbar buttons let you cut, paste, copy, delete.

  4. When finished editing, save the procedure using the Save Procedure toolbar button Save Table toolbar button or Alt+F, S. If you made no changes, choose File, Close (Alt+F, C).

StepsRunning a stored procedure

  1. Select the Procedures & Functions folder from the sample database in the left panel. You may have to expand the database container to do this.

  2. Right-click the procedure in the right panel, for example sp_customer_list.

  3. From the submenu, choose Execute from Interactive SQL (Alt+F,u). Click OK.

  4. Sybase Central starts Interactive SQL, connects to the database, and executes the procedure.

    A call to the sp_customer_list procedure returns a set of customer IDs and company names from the Customer table.

Setting permissions on procedures

Stored procedures have permissions associated with them. In order to execute a procedure, you either need to be granted permission to execute a procedure, or you need to be a member of a user group that has permission to execute the procedure.

StepsViewing and altering procedure permissions

  1. Right-click a procedure and click the Properties toolbar button properties toolbar button or select Properties (Alt+R) from the submenu. A properties sheet displays. (For example, right-click sp_customer_list.)

  2. Click the Permissions tab to see which user IDs have been granted permissions on this procedure. For sp_customer_list, none do, as the only user for the sample database is DBA, who automatically has execute permissions as owner of the procedure.

  3. Click Grant to grant users or groups permission to execute this procedure. Grant permission to execute this procedure to the Public user group by selecting the Public user group icon and clicking OK.

  4. Click Cancel or Apply, then OK.