我正试图从Oracle表中存储的斑点创建缩略图。我可以使用ordimage.processCopy来处理单个行,但是我想在表中的所有行上运行该过程。
我的理解是,我需要创建一个游标,然后遍历游标以处理每一行。目前,我收到错误消息“ ORA-06510:PL / SQL:未处理的用户定义的异常”,并且我的想法不完整。谁能提供一些见识?
DECLARE
cursor photos is select PHOTO_ID from placer_photo;
v_file_content blob;
v_file_display blob;
v_thumb blob;
v_id number;
BEGIN
for i in photos
loop
SELECT photo_id, file_content, file_display, file_thumbnail INTO v_id, v_file_content, v_file_display, v_thumb FROM placer_photo where photo_id = i.photo_id
for update;
/*DBMS_OUTPUT.PUT_LINE(v_id);*/
ordimage.processCopy(v_file_content, 'maxScale=800 800', v_file_display);
ordimage.processCopy(v_file_content, 'maxScale=32 32', v_thumb);
UPDATE placer_photo
SET file_thumbnail = v_thumb,
file_display = v_file_display
where photo_id = i.photo_id;
COMMIT;
end loop;
END;
编辑:成功了。
DECLARE
cursor photos is select * from placer_photo where photo_id = 118 for update;
v_file_content blob;
v_file_display blob;
v_thumb blob;
v_id number;
v_date date;
BEGIN
for i in photos
loop
DBMS_OUTPUT.PUT_LINE(i.photo_id);
v_file_content := i.file_content;
v_file_display := i.file_display;
v_thumb := i.file_thumbnail;
ordimage.processCopy(v_file_content, 'maxScale=800 800', v_file_display);
ordimage.processCopy(v_file_content, 'maxScale=100 100', v_thumb);
update placer_photo
set file_display = v_file_display,
file_thumbnail = v_thumb
where current of photos;
end loop;
END;
答案 0 :(得分:0)
开始工作。不得不改变一些东西。
cursor photos is select * from placer_photo for update;
v_file_content blob;
v_file_display blob;
v_thumb blob;
v_id number;
v_date date;
BEGIN
for i in photos
loop
DBMS_OUTPUT.PUT_LINE(i.photo_id);
v_file_content := i.file_content;
v_file_display := i.file_display;
v_thumb := i.file_thumbnail;
ordimage.processCopy(v_file_content, 'maxScale=800 800', v_file_display);
ordimage.processCopy(v_file_content, 'maxScale=100 100', v_thumb);
update placer_photo
set file_display = v_file_display,
file_thumbnail = v_thumb
where current of photos;
end loop;
END;