473,218 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

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 2064
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
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....
4
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...
2
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
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...
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...
2
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? ...
7
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...
28
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!...
7
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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.