DB2 UDB 8.X on Windows server
A couple of questions:
1.) I am trying to develop some DB2 SQL stored procedures. Dev
environment at UDB v 8.2,
production environment still at UDB v 8.1. Any issues with
migrating these things since the Dev environment does not need a C
compiler and production does?
2.) Main stored procedure calling other stored procedures. Called
SPs simply declare a cursor for
some SQL and open the cursor and return. Problem is iterating through
the result set from the calling SP.
For example, I declare this locator:
DECLARE v_MemberRSLocator RESULT_SET_LOCATOR VARYING;
and later execute the following:
CALL TFBUDB.SMACF_MBR_INFO(SP_POL_NBR_TXT,ERR_CD,ERR_MS G);
ASSOCIATE RESULT SET LOCATOR (v_MemberRSLocator)
WITH PROCEDURE TFBUDB.SMACF_MBR_INFO;
ALLOCATE v_MemberCursor CURSOR FOR RESULT SET v_MemberRSLocator;
WHILE (SQLSTATE = '00000') DO
FETCH FROM v_MemberCursor INTO v_MemberNbr;
-- do whatever with data here
END WHILE;
** It seems to loop once and exit. If I add any statements within the
loop it seems to ignore the stopping condition of SQLSTATE = '00000'
and loop forever.
I think perhaps there must be a better way to handle such a
situtation, as I will have many such loops within the SP , and each
will need to do a significant amount of work with the returned data.
I've got some references on order, but any thoughts and advice
appreciated.
Phil J. 5 3867 PJ******@txfb-ins.com wrote:
DB2 UDB 8.X on Windows server
A couple of questions:
1.) I am trying to develop some DB2 SQL stored procedures. Dev
environment at UDB v 8.2,
production environment still at UDB v 8.1. Any issues with
migrating these things since the Dev environment does not need a C
compiler and production does?
In principle no. As long as you don't try to use the GET/PUT routine
procedures. Just running the DDL will be fine.
BUT: The removal of the C-Compiler was a MAJOR redesign. Your
test-environment shouldn't be fundamentally different from production.
In a mission critical production system I'd have a queasy stomach.
2.) Main stored procedure calling other stored procedures. Called
SPs simply declare a cursor for
some SQL and open the cursor and return. Problem is iterating through
the result set from the calling SP.
For example, I declare this locator:
DECLARE v_MemberRSLocator RESULT_SET_LOCATOR VARYING;
and later execute the following:
CALL TFBUDB.SMACF_MBR_INFO(SP_POL_NBR_TXT,ERR_CD,ERR_MS G);
ASSOCIATE RESULT SET LOCATOR (v_MemberRSLocator)
WITH PROCEDURE TFBUDB.SMACF_MBR_INFO;
ALLOCATE v_MemberCursor CURSOR FOR RESULT SET v_MemberRSLocator;
WHILE (SQLSTATE = '00000') DO
FETCH FROM v_MemberCursor INTO v_MemberNbr;
-- do whatever with data here
END WHILE;
** It seems to loop once and exit. If I add any statements within the
loop it seems to ignore the stopping condition of SQLSTATE = '00000'
and loop forever.
If you have any statement following the FETCH the SQLSTATE is reset.
Hence the endless loop. I'm unclear why you see the exit.
Typically cursor loops are written like this:
readresults: LOOP
FETCH ...
IF SQLCODE = 100 THEN LEAVE readresults; END
END LOOP;
For regular cursors (not resultsets) I prefer FOR:
FOR myrow AS (SELECT c1 FROM T) DO
SET x = myrow.c1 + x;
END FOR;
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
In principle no. As long as you don't try to use the GET/PUT routine
procedures. Just running the DDL will be fine.
BUT: The removal of the C-Compiler was a MAJOR redesign. Your
test-environment shouldn't be fundamentally different from production.
In a mission critical production system I'd have a queasy stomach.
1.) Ok, that is good to know and I will pass that info on to the
powers that be...
2.) This is my main stored procedure and will be calling about 10
other stored procedures,
iterating through the results fetched back, and operating on the data
returned. This is to replace a 2300 line COBOL stored procedure.
So how would I:
Call SP1(p1,p2,p3)
iterate through recordset returned from SP1 until EOF
do a whole lot of stuff with each row's columns
using a result set locator to handle the cursor left open by SP1
without resetting the
stopping case for the iteration
end iterate
Call SP2(p4,p7,p9)
iterate through rs returned from SP2
do a lot of stuff here
with each row returned
end iterate
thanks!
Phil Jackson
If you have any statement following the FETCH the SQLSTATE is reset.
Hence the endless loop. I'm unclear why you see the exit.
Typically cursor loops are written like this:
readresults: LOOP
FETCH ...
IF SQLCODE = 100 THEN LEAVE readresults; END
END LOOP;
For regular cursors (not resultsets) I prefer FOR:
FOR myrow AS (SELECT c1 FROM T) DO
SET x = myrow.c1 + x;
END FOR;
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
PJ******@txfb-ins.com wrote:
>In principle no. As long as you don't try to use the GET/PUT routine procedures. Just running the DDL will be fine. BUT: The removal of the C-Compiler was a MAJOR redesign. Your test-environment shouldn't be fundamentally different from production. In a mission critical production system I'd have a queasy stomach.
1.) Ok, that is good to know and I will pass that info on to the
powers that be...
2.) This is my main stored procedure and will be calling about 10
other stored procedures,
iterating through the results fetched back, and operating on the data
returned. This is to replace a 2300 line COBOL stored procedure.
So how would I:
Call SP1(p1,p2,p3)
iterate through recordset returned from SP1 until EOF
do a whole lot of stuff with each row's columns
using a result set locator to handle the cursor left open by SP1
without resetting the
stopping case for the iteration
end iterate
Call SP2(p4,p7,p9)
iterate through rs returned from SP2
do a lot of stuff here
with each row returned
end iterate
As noted in my previous email.
CALL ..
ALLOCATE/ASSOCIATE...
LOOP
FETCH ...;
IF SQLCODE = 100 THEN LEAVE END IF;
.. all your complex stuff..
END LOOP;
CLOSE..;
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thanks, Serge,
That works like a charm. I now have an approx. 800+ line stored proc
that is calling about 10 other stored procs. My next task is to make
sure that any SQL errors are cascaded back to the client and any DB
work prior to the error is rolled back. Can I wrap up the whole main
stored proc within an "Atomic" wrapper and simply have a handler? A
little fuzzy on the methodology needed to make all of this bullet-
proof as possible.
thanks,
Phil Jackson
As noted in my previous email.
CALL ..
ALLOCATE/ASSOCIATE...
LOOP
FETCH ...;
IF SQLCODE = 100 THEN LEAVE END IF;
.. all your complex stuff..
END LOOP;
CLOSE..;
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
PJ******@txfb-ins.com wrote:
That works like a charm. I now have an approx. 800+ line stored proc
that is calling about 10 other stored procs. My next task is to make
sure that any SQL errors are cascaded back to the client and any DB
work prior to the error is rolled back. Can I wrap up the whole main
stored proc within an "Atomic" wrapper and simply have a handler? A
little fuzzy on the methodology needed to make all of this bullet-
proof as possible.
That will work as long as you're not on an old version of DB2 (*squint*
pre-V8.2 ?). In older versions of DB2 you could not nest BEGIN ATOMIC.
Either way. BEGIN ATOMIC is syntactic sugar for using a SAVEPOINT.
If all you want is return the error to the client you need to do no more.
In the absence of a handler DB2 will pass the error up un handled trough
the CALL statement which will cause your main procedure to fail, roll
back the atomic block and again pass the original error back to your client.
Cheer
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Howard Nease |
last post by:
Hello, everyone. I would appreciate any advice that someone could give me on
my future career path. Here is my situation:
I am a bright Junior in a very well-respected private high school, taking...
|
by: Martin Piper |
last post by:
Hi all.
I've recently landed myself the position of trainee
C++ programmer which I'm extremely pleased about,
but also nervous.
According to the feedback from the interview, I
have a good...
|
by: Andy Dingley |
last post by:
I've just started on a new project and inherited a huge pile of XSLT
(and I use the term "pile" advisedly !) It runs at glacial speed, and
I need to fix this this.
Platform is MSXML 4 / ASP
...
|
by: ma740988 |
last post by:
I'm perusing a slide with roughly 12 bullets spread across 3 pages.
Each bullet reflects 'advice'. I'm ok with all but 1 bullet, more
specifically the bullet that states:
" Avoid the STL unless...
|
by: J Rieggle |
last post by:
Hi there,
I am stuck on a problem that relates to eCommerce sites, but isnt ASP.NET
specific (sorry). The ecommerce site is working in the UK, and products
will be sold in pounds stirling. ...
|
by: Alan Silver |
last post by:
Hello,
MSDN (amongst other places) is full of helpful advice on ways to do data
access, but they all seem geared to wards enterprise applications. Maybe
I'm in a minority, but I don't have those...
|
by: John Paul |
last post by:
I'm thinking of building an e-commerce site in php.
Anyone got any advice in building one?
What is the best way to implement a payment system?
Are any legal issues involved?
Thanks,
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first...
|
by: mesut |
last post by:
Hi colleagues,
I need your advice...
I have approx 1,5 years experience with ASP.NET/VB.NET 2005 and I have
to switch over into C# 2005 language. I don't have experience with C#
2005...
|
by: SM |
last post by:
Hello,
I have a index.php template (2 columns). The right columns contains a
bunch of links (interviews, poems, etc...) The left columns contains
the actual article.
So if I click on a link on...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |