Calling an Oracle procedure with a PL/SQL collection type parameter via .NET

后端 未结 1 607
情歌与酒
情歌与酒 2020-12-11 08:11

I\'m trying to call an Oracle stored procedure via .NET. Normally this isn\'t a problem, but this stored procedure contains a parameter that is a PL/SQL collection type:

相关标签:
1条回答
  • 2020-12-11 08:48

    Procedure call via ODP.NET supports only Associative arrays, i.e. with INDEX BY ..., Nested Tables are not supported.

    One solution is to convert in in your Orale procedure:

    CREATE OR REPLACE PACKAGE test_package_gkeu IS
    
        TYPE test_type IS TABLE OF NUMBER;    
        TYPE test_type_associative IS TABLE OF NUMBER INDEX BY INTEGER;
    
    PROCEDURE TEST1 (pvTest IN test_type_associative ) IS
    
    v test_type := test_type();
    BEGIN
       v.Extend(pvTest.COUNT);
       for i in pvTest.First..pvTest.Last loop
           v(i) := pvTest(i)
       end loop;
    
    select *
    into ...
    from receiver r
    where r.receiverid MEMBER OF (v);
    
    END;
    

    For DML statements consider also this:

    FORALL i IN INDICES OF pvTest 
        INSERT INTO MY_TABLE (COL_A)
        VALUES (pvTest(i));
    
    or 
    
    FORALL i IN INDICES OF pvTest 
        DELETE FROM receiver 
        WHERE receiverid  = pvTest(i);
    
    0 讨论(0)
提交回复
热议问题