看看是什么错误,我晕了`~~
CREATE OR REPLACE PROCEDURE docmapfile_temp_tempid
AS
CURSOR c1
IS
SELECT docid, fileid
FROM docmapfile_temp;
BEGIN
FOR c1rec IN c1
LOOP
UPDATE docmapfile_temp
SET tempid = c1rec.docid + c1rec.fileid
WHERE docid = c1rec.docid AND fileid = c1rec.fileid;
COMMIT;
END LOOP;
END;
/
ORA-06550: 第 2 行, 第 12 列:
PLS-00302: 必须说明 'DOCMAPFILE_TEMP_TEMPID ' 组件
ORA-06550: 第 2 行, 第 3 列:
PL/SQL: Statement ignored
------解决方案--------------------漏了个is?
------解决方案--------------------COMMIT;
END LOOP;
-->
END LOOP;
COMMIT;
------解决方案--------------------END LOOP;
END;
-->
END LOOP;
END docmapfile_temp_tempid;
------解决方案----------------------编译没有错误啊
CREATE OR REPLACE PROCEDURE docmapfile_temp_tempid
AS
CURSOR c1
IS
--SELECT docid, fileid
-- FROM docmapfile_temp;
select * from b_areas;
BEGIN
FOR c1rec IN c1
LOOP
--UPDATE docmapfile_temp
-- SET tempid = c1rec.docid + c1rec.fileid
--WHERE docid = c1rec.docid AND fileid = c1rec.fileid;
dbms_output.put_line (c1rec.area_id);
COMMIT;
END LOOP;
END;
------解决方案--------------------我觉得存储过程本身没有任何错误,建议换一下存储过程名称试一下
------解决方案--------------------SET tempid = c1rec.docid + c1rec.fileid
--这几个字段都是什么类型
如果是字符串要用 || 做连接
------解决方案--------------------昏 有这样写存储过程的吗?
掉了个IS吧 不然
------解决方案--------------------把commit放到循环外面,游标内部不能使用commit语句,因为commit会释放游标拥有的任何锁,如果要更新,因该使用open...for update,但是要求表必须有主键,如果没有逐渐,可以在检索的时候加上ROWID
CREATE OR REPLACE PROCEDURE docmapfile_temp_tempid
AS
CURSOR c1
IS
SELECT docid, fileid
FROM docmapfile_temp;
BEGIN
OPEN c1 For UPDATE;
FETCH ....INTO
LOOP
EXIT WHEN C1%NOTFOUND;
UPDATE docmapfile_temp
SET tempid = c1rec.docid + c1rec.fileid
WHERE CURRENT OF c1;
END LOOP;
COMMIT;
END;