0

我想传递一个嵌套表(点连接中的 OracleTable ?)作为参数来调用包中的存储过程。类型test002_table在包中定义。存储过程代码如下:

create or replace package testPro is
    type test002_table is table of test002%rowtype;  
    procedure testInsert(tbs test002_table);
end testPro;

create or replace package body testPro is
    procedure testInsert(tbs test002_table) is
        i int;
    begin
        delete from test002;
        for i in 1..tbs.count loop
            insert into test002 values tbs(i);    
        end loop;
    end;
end;

用 PL\SQL 编写的测试成功运行:

declare 
tab testpro.test002_table := testpro.test002_table();
item test002%rowtype;
i integer;
begin
  tab.extend();
  item.id:=1;
  item.name:='a';
  item.lev:=5;
  item.age:=55;
  item.address:='das';
  tab(tab.count) := item;
  testPro.testInsert(tab);
  commit;
end;

但我不知道如何使用 dotConnect 调用此过程。我尝试了以下方法但没有成功:

OracleCommand cmd = new OracleCommand();
cmd.Connection = con; //OracleConnection con
cmd.CommandType = System.Data.CommandType.StoredProcedure;
OracleType tp = OracleType.GetObjectType("testPro.test002_table", con);
OracleTable table = new OracleTable(tp);

Dotconnect 找不到类型。如何获得所需的 OracleType 对象?或者这个问题可以通过其他方式解决吗?非常感谢。

4

1 回答 1

0

包中声明的用户定义类型不能在此包之外使用。请全局定义与 OracleTable 类一起使用的类型:

create or replace type test002_type as object(
  -- list here the test002 columns
  c1 number,
  c2 number
);
/
create or replace type test002_table is table of test002_type;
/

JIC:ROWTYPE 是一个 PL/SQL 构造,在 SQL 创建类型语句中无法识别。

于 2014-01-10T13:26:47.567 回答