Jorge
Jorge

Reputation: 155

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;
parameter.DbType = ...

Upvotes: 1

Views: 2293

Answers (1)

anon
anon

Reputation:

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.

Upvotes: 1

Related Questions