一、声明游标,循环打印
--第一种方式
declare
cursor imaa_tmp is
select imaa001,imaa004 from imaa_t where imaaent=100 and imaa001 like '5%';
begin
dbms_output.enable(buffer_size => NULL); --不限制打印的字符串限制
for imaa in imaa_tmp
loop
dbms_output.put_line('料件编号:'||imaa.imaa001);
dbms_output.put_line('料件属性:'||imaa.imaa004);
end loop;
end;
--第二方式 不用declare 声明游标
begin
dbms_output.enable(buffer_size => NULL);
for imaa in (select imaa001,imaa004 from imaa_t where imaaent=100 and imaa001 like '5%')
loop
dbms_output.put_line('料件编号:'||imaa.imaa001);
dbms_output.put_line('料件属性:'||imaa.imaa004);
end loop;
end;
二、带有变量的Demo
三、存储过程
create or replace procedure insert_img is
V_sum integer;
begin
select count(*) into V_sum from imaa_t where imaaent=100;
--commit;
dbms_output.put_line('查询到的料件笔数:'||V_sum);
--return V_sum;
-- return 0;
end insert_img ;
网友评论