ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle INDEX BY Pl/sql数组

oracle INDEX BY Pl/sql数组

原创 Linux操作系统 作者:season0891 时间:2011-02-21 17:22:34 0 删除 编辑

--INDEX BY Pl/sql数组
SET SERVEROUTPUT ON
DECLARE
       TYPE NumberTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
       v_Numbers NumberTab;
BEGIN
     FOR v_Count in 1..10 LOOP
         v_Numbers(v_Count) := v_Count * 10;
     END LOOP;
    
     DBMS_OUTPUT.put_line('Table elements: ');
     FOR v_Count IN 1..10 LOOP
         DBMS_OUTPUT.put_line(' v_Numbers('|| v_Count||'): '||v_Numbers(v_Count));
     END LOOP;
    
  BEGIN
       DBMS_OUTPUT.put_line('v_Numbers(11): '|| v_Numbers(11));
  EXCEPTION
           WHEN NO_DATA_FOUND THEN
                DBMS_OUTPUT.put_line('No data found reading v_Numbers(11)!');
  END;
END;

--INDEX BY Pl/sql数组002
SET SERVEROUTPUT ON
declare
       type T_customerTab is table of t_customer%rowtype index by binary_integer;
       t_customers T_customerTab;
begin
          select * into t_customers(1) from t_customer where rownum = 1;    
          DBMS_OUTPUT.put_line( 'customer_name: '||t_customers(1).customer_id || ' customer_name: '||t_customers(1).customer_name);
end;

COME FROM:http://www.blogjava.net/fine/archive/2007/03/12/103358.html

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/90618/viewspace-687632/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 一个pub友的博客
请登录后发表评论 登录
全部评论

注册时间:2008-06-10

  • 博文量
    790
  • 访问量
    1965893