oracle实体集合赋值

https://www.cnblogs.com/Bouger/p/4318322.html

create or replace package body test_lu is

  ---创建一个自定义数据类型
  TYPE c_user IS RECORD
    (   id number,
        name varchar2(30)
    ); 
  ---根据自定义数据类型创建一个集合
  TYPE c_user_array IS TABLE OF c_user INDEX BY BINARY_INTEGER; 
  ---集合对象
  user_array c_user_array;
  ---数据对象
  user c_user;
  ---计数器
  v_counter number;
        
  procedure test1 is
  begin
    user.id:=1;
    user.name:='luu';
    user_array(user.id):=user;
     
    user.id:=2;
    user.name:='lii';
    user_array(user.id):=user;   
     
  end;
   
  procedure test2 is
  begin
    for v_counter in 1..user_array.count loop
      DBMS_OUTPUT.put_line(user_array(v_counter).id||'...'||user_array(v_counter).name);
    end loop;       
  end;
   
  procedure test3 is
  begin
    test1;
    test2;
  end;
end test_lu;
posted @ 2019-08-06 15:45  MicrosoftMan  阅读(360)  评论(0编辑  收藏  举报