亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

linux - mysql stored procedure error reporting when calling
滿天的星座
滿天的星座 2017-05-31 10:37:32
0
2
939

Please help me find out why the error is reported. This is my first time writing this type of stored procedure:
delimiter $$
create procedure mydb()
begin
declare dbname varchar(50);
declare stop int default 0;
declare cur cursor for (select name from name); //The name table stores the name of the database
declare CONTINUE HANDLER FOR SQLSTATE '02000' SET stop = null;
open cur;
fetch cur into dbname; //Traverse the name of the database
while (stop is not null) do

begin
declare name varchar(200);
declare stop1 int default 0;
declare cur1  cursor for (select prounit_name from dbname.prounit);  //獲取prounit表中prounit_name字段內(nèi)容
declare CONTINUE HANDLER FOR SQLSTATE '02000' SET stop1 = null;
open cur1;
fetch cur1 into name;
while ( stop1 is not null) do
    update prounit set name='abc';
    fetch cur1 into name;
end while;
close cur1;
end ;

fetch cur into dbname;
end while;
close cur;
end ;
delimiter $$

Error when executing stored procedure: ERROR 1146 (42S02): Table 'dbname.prounit' doesn't exist

why??????

滿天的星座
滿天的星座

reply all(2)
淡淡煙草味

The prompt is obvious, the table does not exist
declare dbname varchar(50);The name is overwritten?

迷茫

Let’s talk about some grammar issues.

  1. while (stop is not null) stop in do should be the cursor dbname, and judge the cursor. Otherwise, stop will not be referenced

  2. The last end;, before you defined delimiter $$` with `$$ as the end character, it should be changed to end$$, and finally don’t forget to change the ending to delimiter;

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template