【问题标题】:how to use dotconnect for oracle to call stored procedures with nested table as parameteroracle如何使用dotconnect调用以嵌套表为参数的存储过程
【发布时间】:2014-01-24 03:45:37
【问题描述】:

我想传递一个嵌套表(OracleTable in dotconnection ?)作为参数来调用包中的存储过程。 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 对象?或者这个问题可以通过其他方式解决吗?非常感谢。

【问题讨论】:

    标签: stored-procedures parameters dotconnect nested-table


    【解决方案1】:

    在包中声明的用户定义类型不能在该包之外使用。请全局定义与 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 创建类型语句中无法识别。

    【讨论】:

      猜你喜欢
      • 2011-08-06
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 2011-01-22
      • 2019-10-29
      • 2018-12-21
      相关资源
      最近更新 更多