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

Creating a Function

Functions can improve modularity of applications and code reusability. This section describes how to create a function on the DAS console.

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. Click Change on the right of the current database to switch to the database where you want to create a function.

    Figure 1 Switching to another database

  8. On the displayed Objects page, select Functions. In the upper left corner of the page, click Create Function.

    Figure 2 Creating a function

  9. In the displayed dialog box, enter a function name, returned value type, and description, and click OK.

    Figure 3 Specifying function information

  10. On the displayed page, edit the function body.

    Figure 4 Editing a function body

  11. In the upper left corner, click Option. In the displayed dialog box, set required parameters and click OK.

    Figure 5 Setting required parameters

  12. Click Save or Execute and view the status in the Message area.

    Figure 6 Executing a function