If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Cursor has no rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-10, 06:58
afaqshakoor afaqshakoor is offline
Registered User
 
Join Date: Jan 2009
Posts: 1
Cursor has no rows

I am calling a stored procedure which executes a simple select statement to a table based on a where clause. Using the IBM DB2 UDB provider, iDB2Connection, iDB2Command and iDB2DataAdapter class, I execute the stored procedure and use the iDB2DataAdapter.fill method to populate the Dataset. If no rows are returned, the fill method does not create a Table. Is there any way that I can make the fill method to create a Table with zero (0) rows.

Here's the SP:
CREATE PROCEDURE ReturnData
(IN P1 DECIMAL (7,0))
DYNAMIC RESULT SETS 2
LANGUAGE SQL
P1: BEGIN
DECLARE C1 CURSOR WITH RETURN FOR
SELECT * FROM TABLE1
WHERE TableField = P1;
DECLARE C2 CURSOR WITH RETURN FOR
SELECT * FROM TABLE2
WHERE TableField = P1;
OPEN C1;
OPEN C2;

Here's the C# code:
iDB2Command cmd = new iDB2Command("Call ReturnData (@p1), _iDB2connection);
cmd.DeriveParameters();
cmd.Parameters["@p1"].Value = Convert.ToDecimal("1234");

iDB2DataAdapter ida = new iDB2DataAdapter(cmd);
ds = new DataSet();
ida.Fill(ds, "ReturnData()", " "));

If one of the cursors or both do not have any rows returned, I still want the process to return 2 Tables in the ida (Adapter).

Help will be appreciated.
Reply With Quote
Reply

Tags
blank resultset, db2, resultset

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On