Call Oracle package function using Odbc from C#

て烟熏妆下的殇ゞ 提交于 2019-12-02 04:01:32

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

try

OdbcCommand command = new OdbcCommand("begin ? := TESTUSER.TESTPKG.testfunc(?) end;", connection);

I managed to call the package function like this:

command.CommandText = @"begin
    :ret := ILMTEST.testpkg.testfunc(:n);
end;";
command.CommandType = System.Data.CommandType.Text;

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!