oracle编写存储过程把表1中多条数据插入到表2,求高手指教(错误指向插入sql语句的v_name)
具体代码:createprocedureproc1isCursorcusisselectnamefromstu;v_namevarchar2(20);beginforv_...
具体代码:
create procedure proc1 is
Cursor cus is select name from stu;
v_name varchar2(20);
begin
for v_name in cur loop
insert into stu_two (name) values (v_name);
commit;
end loop;
end;
编译的时候报错pls-00382:expression is of wrong type
着急啊!!!!!! 展开
create procedure proc1 is
Cursor cus is select name from stu;
v_name varchar2(20);
begin
for v_name in cur loop
insert into stu_two (name) values (v_name);
commit;
end loop;
end;
编译的时候报错pls-00382:expression is of wrong type
着急啊!!!!!! 展开
1个回答
展开全部
1、上面定义的变量是CUS下面写的CUR
2、FOR语句的循环变量是光标,需要从光标中提取相应字段
CREATE OR REPLACE PROCEDURE PROC1 IS
CURSOR CUR IS
SELECT NAME FROM STU;
BEGIN
FOR C IN CUR LOOP
INSERT INTO STU_TWO (NAME) VALUES (C.NAME);
COMMIT;
END LOOP;
END;
追问
问题已解决,不过还是谢谢。继续追问个新问题:创建一个job,包含一个存储过程:向表1插入3条数据,一分钟执行一次,执行十次结束,关键是后面的执行十次结束怎么实现?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询