我想创建一个过程与一段时间,但我有一个错误。
步骤如下:
Delimiter //
create procedure procedure1 ()
BEGIN
Declare i INT;
set i=1;
while i< 74 do
execute immediate 'insert into main values(3,"samples")'
set i=1+1;
end while;
end //
我得到了这个错误
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that on for the right syntax to use near ''insert into main values(3,"samples")'
有人有主意吗?
更改过程中的插入查询,如下所示
insert into main values(3,'samples')
像这样使用: -将查询存储到变量
Delimiter //
create procedure procedure1 ()
BEGIN
Declare i INT;
v_Sql VARCHAR2(2000);
set i=1;
v_Sql :='insert into main values(3,"samples")';
while i< 74 do
EXECUTE IMMEDIATE v_Sql ;
set i=1+1;
end while;
end //