mysql 產生完整的預存程序定義語句,mysql預存程序

來源:互聯網
上載者:User

mysql 產生完整的預存程序定義語句,mysql預存程序

 SELECT   CONCAT('PR_', p.db,'.',p.name ) FileName ,CONCAT('DELIMI','TER $$USE `',p.db,'`$$DROP PROCEDURE IF EXISTS `',p.name, '`$$CREATE DEFINER=','`',LEFT(DEFINER, -1+LOCATE('@',DEFINER)),'`@`',RIGHT(DEFINER,LENGTH(DEFINER)-LOCATE('@',DEFINER)),'`',' PROCEDURE `',p.name ,'`(',p.param_list,')',p.body_utf8,'$$DELIMI','TER ;' ) AS sql_create FROM mysql.proc AS p WHERE p.db LIKE '%'AND TYPE LIKE 'PROC%'ORDER BY p.db,p.name ;


MySQL裡面sql語句調用預存程序,該怎寫?

call sp_add();
是不是你已定義流程有問題吧,並沒有指出返回結果來
像我這樣是可以的:

CREATE PROCEDURE sp_add(a int, b int,out c int)
begin

set c=a+ b;

end;
調用過程:
call sp_add (1,2,@a);
select @a;
 
mysql怎在不建立函數或者預存程序的時單獨執行塊內的語句

mysql沒有塊的概念,單獨的塊,如下
BEGIN
INSERT INTO liu_test VALUE ('aa','bb');
END
這種塊是不能執行的。
單獨塊執行最好的辦法還是建預存程序,執行結束再刪除預存程序 。
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.