473,698 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CAN WE MAKE USE OF CURSORS IN A SIMPLE BLOCK IN DB2?

nsd
HI ALL,

HERE I HAVE MADE USE OF SAME CURSOR DECLARATIONS AND USAGE IN THE
FOLLOWING TWO DB2 CODES .
BUT I AM GETTING AN ERROR IN THE FIRST CASE i.e CURSOR IN A SIMPLE
BLOCK.

SO I HAVE A QUESTION...
CAN WE MAKE USE OF CURSORS IN A SIMPLE BLOCK?

NOTE: WE CAN MAKE USE OF IT IN CASE OF ORACLE.
PL. HAVE A LOOK AT THE FOLLOWING CODES

-----------------------------------------------------------
1). CURSOR INSIDE A SIMPLE BLOCK (giving error)
-----------------------------------------------------------
BEGIN ATOMIC
DECLARE v_sno INTEGER;
DECLARE my_cur CURSOR FOR SELECT sno FROM t_testforcur;
OPEN my_cur;
FETCH FROM my_cur INTO v_sno;
CLOSE my_cur;
END@
-----------------------------------------------------------

-----------------------------------------------------------
2). CURSOR INSIDE A PROCEDURE
-----------------------------------------------------------
CREATE PROCEDURE p_testforcur( )
LANGUAGE SQL
SPECIFIC p_test
BEGIN ATOMIC
DECLARE v_sno INTEGER;
DECLARE my_cur CURSOR FOR SELECT sno FROM t_testforcur;
OPEN my_cur;
FETCH FROM my_cur INTO v_sno;
CLOSE my_cur;
END@
------------------------------------------------------------

regards,
nsd

Nov 12 '05 #1
2 2083
Please see "SQL Reference Volume 2 Version 8.2" --> Statements.
And compare Compound SQL(Dynamic), Compound SQL(Embedded) and Compound
SQL(Procedure). In their descriptions, usable SQL statements for each
Compound SQLs are documented. For first two Compound SQLs, you can't
use CURSOR related statements inside the Compound SQL statements.
But, you can use cursor by embedded within an application program, if
it is not inside a compound SQL.

Nov 12 '05 #2
nsd wrote:
HI ALL,

HERE I HAVE MADE USE OF SAME CURSOR DECLARATIONS AND USAGE IN THE
FOLLOWING TWO DB2 CODES .
BUT I AM GETTING AN ERROR IN THE FIRST CASE i.e CURSOR IN A SIMPLE
BLOCK.

SO I HAVE A QUESTION...
CAN WE MAKE USE OF CURSORS IN A SIMPLE BLOCK?

NOTE: WE CAN MAKE USE OF IT IN CASE OF ORACLE.
PL. HAVE A LOOK AT THE FOLLOWING CODES

-----------------------------------------------------------
1). CURSOR INSIDE A SIMPLE BLOCK (giving error)
-----------------------------------------------------------
BEGIN ATOMIC
DECLARE v_sno INTEGER;
DECLARE my_cur CURSOR FOR SELECT sno FROM t_testforcur;
OPEN my_cur;
FETCH FROM my_cur INTO v_sno;
CLOSE my_cur;
END@ this is "inline" SQL PL. see compound statement (dynamic) for the
supported statements.
Try FOR loop instead.
-----------------------------------------------------------

-----------------------------------------------------------
2). CURSOR INSIDE A PROCEDURE
-----------------------------------------------------------
CREATE PROCEDURE p_testforcur( )
LANGUAGE SQL
SPECIFIC p_test
BEGIN ATOMIC
DECLARE v_sno INTEGER;
DECLARE my_cur CURSOR FOR SELECT sno FROM t_testforcur;
OPEN my_cur;
FETCH FROM my_cur INTO v_sno;
CLOSE my_cur;
END@

regular SQL PL as defined in compound statement (procedure)

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10013
by: Guillaume Mallet | last post by:
Hi, Version : Oracle 8.1.7.0.0 I'm running a batch application that basically performs a potentially high number of SELECT queries (a minor proportion of UPDATEs as well), using the OCI. After some 300 statements get executed, I'm faced with the recurrent ORA-01000 error message that says "maximum open cursors exceeded". I checked my OCIHandleFree() calls, there's no mismatch, meaning they match the calls
4
10742
by: bourgon | last post by:
Working on some new code, I'm coming across WHILE loops used instead of cursors. I was curious if anyone had any stats on how the speed of doing this compares to the speed of a cursor. I typically avoid cursors for performance sake, but I'm not sure how this avoids the speed hit of a cursor, since it's doing essentially the same thing. Many thanks.
2
4178
by: cmitchell | last post by:
Hi just wondering where i can see the maximum amount of open cursors allowed at one time? I am using DB2 UDB for Windows 8.1.5. Thanks.. Cheryl
6
2508
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 set it back to cursors.default when the thread ends (using a callback)
5
1382
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 directory or in resource file? Thanks, Boni
2
4015
by: Lars Netzel | last post by:
Is it hard to make a Print button from a Windows Form that will print a number of fields from an Access database in a fairly formatted way? How does this work with the Print Dialoges and stuff? I do NOT want to involve Crystal Reports! Been there and never want to do it again. :) /Lars
7
3549
by: H. Williams | last post by:
I know the .Net Cursor class doesn't work with color cursors. So I'm currently using the LoadCursorFromFile API with reflection to set color cursors: here is my code: public static extern IntPtr LoadCursorFromFile( string fileName ); IntPtr hwdCursor= LoadCursorFromFile( "color.cur" ); myCursor.GetType().InvokeMember("handle",BindingFlags.Public |
28
2935
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions! PEP: 359 Title: The "make" Statement Version: $Revision: 45366 $ Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $
7
2694
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
0
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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 we have to send another system

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.