看《Oracle 9i10g编程艺术》里的例子,怎么创建不起来?HR > create or replace type emp_type
  2  as object
  3  (empno number(4),
  4  ename varchar2(10),
  5  job varchar2(9),
  6  mgr number(4),
  7  hiredate date,
  8   sal number(7,2),
  9  comm number(7,2));
 10  /Type created.HR > create or replace type emp_tab_type
  2  as table of emp_type;
  3  /Type created.HR > create table dept_and_emp
  2  (deptno number(2) primary key,
  3  dname varchar2(14),
  4  loc varchar2(13),
  5  emps emp_tab_type);
emps emp_tab_type)
*
ERROR at line 5:
ORA-22913: must specify table name for nested table column or attribute

解决方案 »

  1.   


    ORA-22913 must specify table name for nested table column or attributeCause: The storage clause is not specified for a nested table column or attribute.Action: Specify the nested table storage clause for the nested table column or attribute.
      

  2.   

    SQL> create table dept_and_emp
      2  (deptno number(2) primary key,
      3   dname varchar2(14),
      4   loc varchar2(13),
      5   emps emp_type);
     
    Table created不要用嵌套表的嵌套。
      

  3.   

    create or replace type emp_type
       as object
       (empno number(4),
       ename varchar2(10),
       job varchar2(9),
       mgr number(4),
       hiredate date,
       sal number(7,2),
      comm number(7,2));
    create     table   emp_tab_type   of   emp_type;       ;
     
     create table dept_and_emp
       (deptno number(2) primary key,
       dname varchar2(14),
      loc varchar2(13),
      emps    ref   emp_type   scope   is   emp_tab_type);
    --改成这样子!
      

  4.   

    --TEST DATA: 
    insert   into   emp_tab_type   values(11,',11','1111',11,sysdate,8.0,7.0)
     
     insert   into   dept_and_emp     select   11,   '1122','2222' , ref(a)  from   emp_tab_type   a         where   empno=11
    --USING:
    select  deptno,dname,loc,deref(emps)  from   dept_and_emp--RESULT:
    1 11 1122 2222 11 ,11 1111 11 2011-9-30 10:41:31 8.00 7.00
    --不要太看书本!