pl/sql 中for和while循环([PL/SQL] 用For Loop 替代Cursor)
for循环:
[PL/SQL] 用For Loop 替代Cursor
http://www.itwenzhai.com/data/2006/0523/article_9377.htm
http://blog.csdn.net/heyday/archive/2005/07/27/435804.aspx
CURSOR FOR Loop
FOR employee_rec in c1 ---employee_rec直接用,不用提前定义
LOOP
total_val := total_val + employee_rec.monthly_income;
END LOOP;
当使用CURSOR FOR Loop时,不用我手工open cursor close cursor
应用:
begin
FOR emm IN ( SELECT ro_site, ns_site, product_line, wh_type
FROM eis_hq_invhl_mail_data
WHERE report_type = 'Detailed' )
LOOP
DBMS_OUTPUT.put_line( emm.product_line );
eis_hq_invhl_pkg.make_mail_detailed_data
( p_ro_site => emm.ro_site,
p_ns_site => emm.ns_site,
p_product_line => emm.product_line,
p_wh_type => emm.wh_type,
p_current_day => to_date('2005-11-07','yyyy-MM-dd') );
END LOOP;
end;
存储过程DIY2----游标与循环
http://blog.csdn.net/brave1/archive/2005/06/08/390160.aspx
while循环:
WHILE( i <= CEIL( LENGTH( p_clob_data ) / 4000 ))
LOOP
v_clob_data := TRIM( SUBSTR( p_clob_data,
i * 4000,
4000 ));
DBMS_OUTPUT.put_line( SUBSTR( v_clob_data,
0,
255 ));
i := i + 1;
END LOOP;
[PL/SQL] 用For Loop 替代Cursor
http://www.itwenzhai.com/data/2006/0523/article_9377.htm
http://blog.csdn.net/heyday/archive/2005/07/27/435804.aspx
CURSOR FOR Loop
FOR employee_rec in c1 ---employee_rec直接用,不用提前定义
LOOP
total_val := total_val + employee_rec.monthly_income;
END LOOP;
当使用CURSOR FOR Loop时,不用我手工open cursor close cursor
应用:
begin
FOR emm IN ( SELECT ro_site, ns_site, product_line, wh_type
FROM eis_hq_invhl_mail_data
WHERE report_type = 'Detailed' )
LOOP
DBMS_OUTPUT.put_line( emm.product_line );
eis_hq_invhl_pkg.make_mail_detailed_data
( p_ro_site => emm.ro_site,
p_ns_site => emm.ns_site,
p_product_line => emm.product_line,
p_wh_type => emm.wh_type,
p_current_day => to_date('2005-11-07','yyyy-MM-dd') );
END LOOP;
end;
存储过程DIY2----游标与循环
http://blog.csdn.net/brave1/archive/2005/06/08/390160.aspx
while循环:
WHILE( i <= CEIL( LENGTH( p_clob_data ) / 4000 ))
LOOP
v_clob_data := TRIM( SUBSTR( p_clob_data,
i * 4000,
4000 ));
DBMS_OUTPUT.put_line( SUBSTR( v_clob_data,
0,
255 ));
i := i + 1;
END LOOP;