SQL Prompt 5

Encapsulating SQL as a new stored procedure

Encapsulating SQL as a new stored procedure is available only in SQL Prompt Pro Edition.

SQL Prompt allows you to create a new stored procedure from any block of valid SQL. To encapsulate SQL as a new stored procedure:

  1. Open the SQL script you want to encapsulate in a query window.
  2. Select the section of the script that you want to use for the new stored procedure. Parameters are created from variables in the script, therefore it is recommended that you declare any variables in the SQL you select.

    If there are syntax errors in the SQL you select, SQL Prompt cannot create a new stored procedure.
  3. On the SQL Prompt menu, click Encapsulate As New Stored Procedure.
    The Encapsulate As New Stored Procedure wizard is displayed:
  4. In the Owner box, type the name of the owner for the new stored procedure.
  5. In the Name box, type a name for the new stored procedure.
    Note that SQL Prompt does not check for duplicate names. If a stored procedure with this owner and name already exists, the SQL script to create the new stored procedure will fail when you run it.
    Variables that will be used to create parameters are listed in the Parameters box. SQL Prompt automatically determines whether each variable will be an input parameter or an output parameter.
  6. In the Parameters box, reorder the parameters as required using the and buttons.
    If a warning triangle is displayed by a parameter, move your mouse over the warning triangle to see details of the warning.
    The SQL script to create the new stored procedure is displayed in the Preview box.
  7. Click Next.
    The second page of the wizard is displayed:
  8. If you do not want the new stored procedure to replace the SQL you selected, under Source SQL, select Do not replace.
    The Preview box now displays the SQL you selected, and shows how it will be modified if you chose to replace it with a reference to the new stored procedure.
  9. Click View Script.
    The SQL script to create the stored procedure is displayed in a new query window.
    If you selected Replace with reference to new stored procedure, SQL Prompt replaces the SQL you selected with a reference to the new stored procedure.
  10. Edit the stored procedure creation script if required, and run it.
    The new stored procedure is created.

Keyboard shortcut: hold Ctrl and press B then E to encapsulate the selected script as a new stored procedure. (SQL Prompt 5.3 only)


Didn't find what you were looking for?