我的RECORD学习

很多ERP中需要一个RECORD技术,如下是一个应用比较完整的例子,可以找到对应的RECORD属性:my_dept(i),my_dept.count,my_dept.exists(i),my_dept.first,my_dept.last,my_dept(i).deptno
set serveroutput on
set echo off
select * from dept
/
declare
  type dept_table_type is table of dept%rowtype
    index by binary_integer;
    my_dept    dept_table_type;
    v_count    number(2);
    v_rows     number(2);
begin
  select count(*) into v_count
  from dept;
  for i in 1..v_count loop
    select  *
    into  my_dept(i)
    from  dept
    where  deptno  =  i*10;
  end loop;
  v_rows:=my_dept.count;
  dbms_output.put_line('Contains..... '||to_char(v_rows));
  for i in 1..v_rows loop
    if  my_dept.exists(i)  then
      dbms_output.put_line('DEPT Name : '||
        to_char(i)||' - '||my_dept(i).dname);
    end  if;
  end loop;
  dbms_output.put_line('prior(2) : '||to_char(my_dept.prior(2))); 
  dbms_output.put_line('delete(2)........'); 
  my_dept.delete(2);
  for i in 1..v_rows loop
    if  my_dept.exists(i)  then
      dbms_output.put_line('LOC : '||
        to_char(i)||' - '||my_dept(i).loc);
    end  if;
  end loop;
  dbms_output.put_line('delete(4)........'); 
  my_dept.delete(4);
  for i in 1..v_rows loop
    if  my_dept.exists(i)  then
      dbms_output.put_line('DEPT No : '||
        to_char(i)||' - '||my_dept(i).deptno);
    end  if;   
  end loop;
  v_rows:=my_dept.count;
  dbms_output.put_line('Contains '||to_char(v_rows));
  dbms_output.put_line('First :  '||to_char(my_dept.first));
  dbms_output.put_line('Last :   '||to_char(my_dept.last));
end; 

set echo on
set serveroutput off
 

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

转载于:http://blog.itpub.net/13941341/viewspace-624017/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值