2014-01-06 23 views
0

我想通过嵌套表(OracleTable in dotconnection?)作为参数来调用存储过程的包。在包中定义了类型 test002_table。存储过程的代码如下:如何使用dotconnect for oracle以嵌套表的形式调用存储过程作为参数

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所需的对象?或者可以用其他方式解决这个问题?非常感谢。

回答

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语句类型无法识别。

相关问题