ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 我的RECORD学习

我的RECORD学习

原创 Linux操作系统 作者:shuiyu131 时间:2009-12-30 18:44:38 0 删除 编辑
很多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博客 ” ,链接:https://blog.itpub.net/13941341/viewspace-624017/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: oracle 的trigger
下一篇: 我的RECORD学习2
请登录后发表评论 登录
全部评论

注册时间:2008-09-08

  • 博文量
    14
  • 访问量
    13957