declare
--定义一个变量
icount number(18);
begin
for cur_entry in (
--查询的语句根据目录号、用户查询出entry_id,案卷号
select entry_id,file_code from am_c_entry where catalogue_code='B-11-1-11' and
created_by='sa'
) loop
--变量初始值
icount:=0;
execute immediate '
select count(*) from am_c_page where entry_id='||cur_entry.entry_id into icount;
--输出符合条件的结果
dbms_output.put_line('案卷号:'||cur_entry.file_code||'影像数:'||icount);
end loop;
end;
输出如下:
案卷号:1影像数:8