MySql:如何在声明语句之前调用存储过程 [英] MySql: How to call a stored procedure before declare statements
问题描述
我需要在声明游标之前调用 sp.sp 填充一个表,然后在这个表的行中循环游标.但是工作台不允许在 declare
语句之前调用 sp 或其他任何东西.
create definer=`root`@`%` 过程`usp_test`()开始声明 ordid int;声明packid int;声明 cstmid int;声明 deltimespanid int;声明 dstrcid int;声明 pcstatus tinyint(1);申报交货时间日期时间;声明 maxdate 日期时间;声明 temppackcount int default(0);调用 usp_createtemppackages;-- 它说这里有语法错误声明 crs 游标从临时包中选择 *....
我该如何称呼这个 sp ?
DECLARE 语句必须是存储过程中的第一个.
考虑 - 1) 在调用 usp_testst 之前调用 usp_createtemppackages 2) 将 usp_createtemppackages 功能集成到 usp_testst 3) 移除游标并以其他方式迭代表(这也可能会提高性能,因为游标有点慢).>
I need call sp before declaring a cursor. The sp fills a table and then the cursor loop in this tables rows. But workbench does not allow call sp or anything else before declare
statements.
create definer=`root`@`%` procedure `usp_tesst`()
begin
declare ordid int;
declare packid int;
declare cstmid int;
declare deltimespanid int;
declare dstrcid int;
declare pcstatus tinyint(1);
declare deliverytime datetime;
declare maxdate datetime;
declare temppackcount int default(0);
call usp_createtemppackages;
-- it says there is a syntax error in here
declare crs cursor for
select * from temppackages....
How should I call this sp ?
DECLARE statements must be first in Stored Procedures.
Consider either - 1) calling usp_createtemppackages before calling usp_tesst 2) integrating usp_createtemppackages functionality into usp_tesst 3) Removing the cursor and iterating the table some other way (which may give a performance increase too as cursors are a bit slow).
这篇关于MySql:如何在声明语句之前调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!