How to call a DB2 stored procedure from C#?
I use DB2 9.7 for Linux. The stored procedure is implemented in PL/SQL (Oracle's programming language), so, the record set is an output parameter (SYS_REFCURSOR).
CREATE OR REPLACE PROCEDURE TEST_CURSOR (
CV_1 OUT SYS_REFCURSOR
) IS
BEGIN
OPEN CV_1 FOR
SELECT 1 COLUMN
FROM DUAL;
END TEST_CURSOR;
I don't know how to declare this parameter in my C# code.
DB2Parameter parameter = ((DB2Command)command).CreateParameter();
parameter.ParameterName = "cv_1";
parameter.Direction = ParameterDirection.Output;
parame开发者_开发技巧ter.DbType = ...
There is no DB2Type enumeration for result sets. In their API the way you do this is to execute the command with the DB2Command.ExecuteReader method. You may have to change the PL/SQL to a function which returns a sys_refcursor rather than a procedure which has a sys_refcursor parameter.
精彩评论