Call Oracle package function using Odbc from C#

前端 未结 4 1502
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 16:47

I have a function defined inside an Oracle package:

CREATE OR REPLACE PACKAGE BODY TESTUSER.TESTPKG as
  FUNCTION testfunc(n IN NUMBER) RETURN NUMBER as
  begin
         


        
相关标签:
4条回答
  • 2021-01-24 17:10

    I think you should consider using the Oracle Client instead.

    And if you choose ODBC to have just to create a DSN and then connect to it to be somehow database agnostic, consider using Enterprise Library Data Access Application Block.

    0 讨论(0)
  • 2021-01-24 17:13

    try

    OdbcCommand command = new OdbcCommand("begin ? := TESTUSER.TESTPKG.testfunc(?) end;", connection);
    
    0 讨论(0)
  • 2021-01-24 17:22

    In the past I would use something like to following for the command string:

    "{? = CALL JF_TESTUSER.TESTPKG.testFunc(?)}"

    See the following article for more information

    0 讨论(0)
  • 2021-01-24 17:24

    I managed to call the package function like this:

    command.CommandText = @"begin
        :ret := ILMTEST.testpkg.testfunc(:n);
    end;";
    command.CommandType = System.Data.CommandType.Text;
    
    0 讨论(0)
提交回复
热议问题