473,471 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Not able to close cursors.

1 New Member
Hi,
I am new to DB2. I have created a stored proc and have DECLARED a Cursor on a TEMPORAY TABLE. When I execute this SP from a .Net code using command.Executereader it leaves a cursor open even after closing the Reader.

BUT If DECLARE my cursor on a database table and NOT on TEMPORARY Table, cursor is closed as soon as I close the datareader.

Can anybody tell me why is this cursor behaving differently depending on what is an underlying table.

This is a dummy SP that I am trying to execute

******************************************
CREATE PROCEDURE TEST1SP ( )
RESULT SETS 1
LANGUAGE SQL
FENCED
COLLID NULLID
WLM ENVIRONMENT D2TAENV3
RUN OPTIONS 'NOTEST(NONE,*,*,*)'
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
P1: BEGIN
-- SQLState 42704 is set when dropping temporary table if it doesn't exist
DECLARE err_drop_temp condition for '42704';
DECLARE err_dummy INTEGER default 0;

-- Declare cursor
DECLARE SANCUR_1 CURSOR WITH RETURN FOR
SELECT C_S_VIN, C_S_VRM
FROM SESSION.TESTTEMP;

-- Drop the temporary table, continuing if it didn't exist.
DECLARE CONTINUE HANDLER FOR err_drop_temp set err_dummy = 1;
DROP TABLE Session.TESTTEMP;

DECLARE GLOBAL TEMPORARY TABLE TESTTEMP
(
C_S_VIN CHAR(25),
C_S_VRM CHAR(12)
)
ON COMMIT PRESERVE ROWS;

INSERT INTO SESSION.TESTTEMP(C_S_VIN, C_S_VRM)
SELECT C_S_VIN, C_S_VRM
FROM T002_DVLAREG
WHERE C_S_VRM='P817SPV';


-- Cursor left open for client application
OPEN SANCUR_1;
END P1

**********************************

Thanks in advance.

Sandeep
Mar 15 '07 #1
0 1410

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: T.S.Negi | last post by:
Hi All, I want to avoid using cursors and loops in stored procedures. Please suggest alternate solutions with example (if possible). Any suggestion in these regards will be appreciated. ...
5
by: Todd Huish | last post by:
I have noticed something disturbing when retrieving datasets over a relatively slow line (multiple T1). I am looking at about 25 seconds to retrieve 500 rows via a php-odbc link. This same select...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
6
by: a | last post by:
Hello, I am doing some multithreading in an MDI app, and I can't seem to get the cursor to stay as an Hourglass. I call: Cursor.Current = cursors.wait at the beginning of my routing, and...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
5
by: Boni | last post by:
Dear all, 1.Is there a standard set of cursors in windows which can be used? If yes, where. I need a "hand"- cursor for drag-drop operation. 2. What is a best practice to place cursors? In app...
3
by: schwartzenberg | last post by:
Dear friends, I have just run into a strange DB2 problem. Something i'd some of you would answer, if only shortly. My basic question is: How do i ensure 'insensitive' (ie static) cursors...
3
dmjpro
by: dmjpro | last post by:
My web application sometimes exceeds the maximum open cursors.. My database server is oracle9i. I want to reutilize the connection without closing the connection. How can i trap the idle cursors...
1
by: Dima Kuchin | last post by:
Hello, I was trying to find the information about when and where should I use cursors in DB2, no luck. Maybe you can point me to some article that describes just that (or tell me which page is...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.