MYSQL Procedure调用表中保存的查询

时间:2015-04-17 17:50:05

标签: mysql stored-procedures

我需要的是

  1. 将所有查询保存在一个表中

    query_id | sql_query
    1        | select * from ms_user
    2        | select * from ms_privileges
    
  2. 创建程序 这个程序将调用

    call my_procedure(query_id)
    
  3. 我尝试了以下代码

    DROP PROCEDURE IF EXISTS mp_test; 
    CREATE PROCEDURE global_procedire(IN id_query int(10));
    BEGIN 
      SET @Query = 'SELECT sql_query from ms_query where query_id = id_query';
      SET @Query = CONCAT(@Query);
      PREPARE stmt FROM @Query; 
      EXECUTE stmt; 
    END
    

0 个答案:

没有答案