This Is A FineDay

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  93 随笔 :: 0 文章 :: 69 评论 :: 0 Trackbacks

--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;

posted on 2007-03-12 17:31 Peter Pan 阅读(1166) 评论(0)  编辑  收藏 所属分类: DB

只有注册用户登录后才能发表评论。


网站导航: