Updated on 2023-12-13 GMT+08:00

Creating a Stored Procedure

A stored procedure consists of a set of SQL statements that can complete specific tasks or process complex services. This section describes how to create a stored procedure. You can use loop statements in a stored procedure to insert objects repeatedly.

Prerequisites

  • You have obtained the CREATE ROUTINE permission.
  • You have obtained the EXECUTE permission.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane on the left, choose Development Tool.

    You can also click Go to Development Tool on the overview page.

  5. Locate the DB instance that you want to log in to and click Log In in the Operation column.
  6. On the top menu bar, choose Database Management.
  7. On the displayed Objects page, select Stored Procedures. In the upper left corner of the page, click Create Stored Procedure.

    Figure 1 Creating a stored procedure

  8. In the displayed dialog box, enter a stored procedure name and description.

    Figure 2 Specifying stored procedure information

  9. Click OK.
  10. On the displayed page, click Option, set the required parameters, and click OK. Then, save and execute the stored procedure.

    Figure 3 Setting parameters

  11. View the execution status in the Message area.

    Figure 4 Viewing the execution of the stored procedure