All Products
Search
Document Center

ApsaraDB RDS:Create and view RDS MySQL stored procedure

Last Updated:Aug 24, 2023

Create a procedure

You can use a DMS or MySQL client to log on to apsaradb for RDS and create a stored procedure. The sample code is as follows:

DROP PROCEDURE IF EXISTS TEST_PROC
DELIMITER //
CREATE PROCEDURE TEST_PROC(IN ID int,OUT NAME VARCHAR(50))
BEGIN
IF(ID = 1) THEN SET NAME = 'test1';
END IF;
IF(ID = 2) THEN SET NAME = 'test2';
END IF;
SELECT version();
END //;

View the stored procedure

In RDS for MySQL, there are two methods to view stored procedure in a database:

  • Query by system table
    Log on to the database and run the following command:
    select * from mysql.proc where db='' and type='procedure' order by name
  • Query by show status

    Log on to the database and run the following command:

    show procedure status
    show create procedure \G