Oracle 在类型表中存储对象值

Oracle 在类型表中存储对象值,oracle,plsql,Oracle,Plsql,下面是将对象值存储在table类型的数组中的代码 对象创建: Create or replace type t_loc as Object ( name varchar2(255 byte), idt char(2) ); PLSQL块 set serveroutput on; declare TYPE test1 IS TABLE OF VARCHAR2(100) INDEX BY t_loc; test2 test1;

下面是将对象值存储在table类型的数组中的代码

对象创建:

Create or replace type t_loc as Object
    (
      name varchar2(255 byte),
      idt char(2)
    );
PLSQL块

set serveroutput on;
  declare 
     TYPE test1 IS TABLE OF VARCHAR2(100) INDEX BY t_loc;
     test2 test1;
  begin
    test2('abad')  := t_loc('ahmedabad','CT');
    test2('bang')  := t_loc('bangalure','S');
    test2('surat')  :=t_loc('Surat','C');

    dbms_output.put_line(test2('surat'));

  end;
我不能编译上面的代码。
在oracle中不可能吗?还是有什么问题?

我得到了解决方案,下面是代码

set serveroutput on;
      declare 
         TYPE test1 IS TABLE OF t_loc INDEX BY varchar2(100);
         test2 test1;
      begin
        test2('abad')  := t_loc('ahmedabad','CT');
        test2('bang')  := t_loc('bangalure','S');
        test2('surat')  :=t_loc('Surat','C');

        dbms_output.put_line(test2('surat').name);

      end;

是否需要按自定义类型索引的字符串表?还是要自定义类型的表,并按字符串索引?无论如何,
test1
的声明与下面的使用方式不匹配

请尝试以下代码:

declare 
    TYPE test1 IS TABLE OF t_loc INDEX BY VARCHAR2(100);
    test2 test1;
begin
    test2('abad')  := t_loc('ahmedabad','CT');
    test2('bang')  := t_loc('bangalure','S');
    test2('surat') := t_loc('Surat','C');

    dbms_output.put_line(test2('surat').name);
end;
/