473,800 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help on SP with GTT

Hi!

We are having problems with an SQL stored proc that uses Global
Temporary Tables. The SP creates the GTT as follows:
DECLARE GLOBAL TEMPORARY TABLE TEMP_ENTRIES (field1, field2, etc)
ON COMMIT PRESERVE ROWS NOT LOGGED IN TEMP_SPACE

The table is then filled with records from other permanent tables
using:
INSERT INTO SESSION.TEMP_EN TRIES SELECT fields FROM table1, table2
WHERE condition

Not all fields are filled.

A cursor is declared to read all the records in the table then enters
a loop to update the blank fields of each row as follows:
FETCH FROM cursorname INTO fieldx, fieldy, etc
[process data]
UPDATE SESSION.TEMP_EN TRIES SET fields WHERE keyfield = value

The loop is controlled by the at_end variable set by the command:
DECLARE CONTINUE HANDLER FOR NOT_FOUND SET at_end = 1

It's supposed to exit the loop when at_end = 1, i.e., there are no
more records in the GTT. Then it uses the contents of the GTT to
insert records into a permanent table.

Our test case involved inserting 2 records into the GTT. Everything
works fine when testing it using the Stored Procedure Builder or when
we have a VB.Net (in Windows XP) or COBOL (in AIX) program run it.
Both records are written to the permanent table. The problem comes out
when we invoke the SP using a COBOL program written as an SP. After
processing the first record, the at_end variable is immediately set to
1 and exits the loop. I couldn't find any bug in the COBOL SP that may
have caused it. I tried increasing the APP_CTL_HEAP_SZ and APPLHEAPSZ
from 128 to 512 (thinking that there wasn't enough memory) but still
nothing. I have absolutely no idea what to do next.

NOTE: The COBOL SP is called by a VB program in Windows or a COBOL
program in AIX. Neither of them works.

Please help!!!

Environment is as follows:
AIX 5.2
UDB 7.2
MFCOBOL OCDS 4.1

Thanks in advance.

Pompeyo C
Aug 8 '08 #1
6 2961
Although I felt that your description of processing logic of SP is too
general to say accurate things, I had some questions...
1) To what value was at_end initialized? And at where?
2-1) Is the loop to update the blank fields neccesary?
Is it possible to be replaced by an UPDATE statement with something
like CASE expressions and/or appropriate WHERE conditions?
2-2) or is it possible by using expressions in the SELECT list of
first INSERT statement(witho ut using the UPDATE statement)?
INSERT INTO SESSION.TEMP_EN TRIES SELECT fields/* change these by
expressions to replace blanks */ FROM table1, table2
WHERE condition
Aug 8 '08 #2
On Aug 8, 4:13*pm, Tonkuma <tonk...@fiberb it.netwrote:
Although I felt that your description of processing logic of SP is too
general to say accurate things, I had some questions...
1) To what value was at_end initialized? And at where?
2-1) Is the loop to update the blank fields neccesary?
*Is it possible to be replaced by an UPDATE statement with something
like CASE expressions and/or appropriate WHERE conditions?
2-2) or is it possible by using expressions in the SELECT list of
first INSERT statement(witho ut using the UPDATE statement)?
INSERT INTO SESSION.TEMP_EN TRIES SELECT fields/* change these by
expressions to replace blanks */ FROM table1, table2
WHERE condition
Thanks for the immediate reply. To answer your questions:
1) The at_end variable was initialized to 0 before the DECLARE CURSOR
and DECLARE CONTINUE HANDLER statements with the command:
DECLARE at_end INT DEFAULT 0
2-1 and 2-2) Unfortunately, yes the loop is necessary because it needs
to call 2 other SP's to process the data in each row, which also means
I can't change the INSERT statement to get all the data

I'd be happy to send more info if you wish. I just took the major
parts of the program to make the message shorter.

Thanks!

Pompeyo C
Aug 8 '08 #3
pompeyoc wrote:
On Aug 8, 4:13 pm, Tonkuma <tonk...@fiberb it.netwrote:
>Although I felt that your description of processing logic of SP is too
general to say accurate things, I had some questions...
1) To what value was at_end initialized? And at where?
2-1) Is the loop to update the blank fields neccesary?
Is it possible to be replaced by an UPDATE statement with something
like CASE expressions and/or appropriate WHERE conditions?
2-2) or is it possible by using expressions in the SELECT list of
first INSERT statement(witho ut using the UPDATE statement)?
INSERT INTO SESSION.TEMP_EN TRIES SELECT fields/* change these by
expressions to replace blanks */ FROM table1, table2
WHERE condition

Thanks for the immediate reply. To answer your questions:
1) The at_end variable was initialized to 0 before the DECLARE CURSOR
and DECLARE CONTINUE HANDLER statements with the command:
DECLARE at_end INT DEFAULT 0
2-1 and 2-2) Unfortunately, yes the loop is necessary because it needs
to call 2 other SP's to process the data in each row, which also means
I can't change the INSERT statement to get all the data

I'd be happy to send more info if you wish. I just took the major
parts of the program to make the message shorter.
Ar eyou sure teh variable is actually set and you do not receive a
different error.
One way fro a caller to mess with what teh callee does is to mark the
caller as READS SQL DATA. In that case your INSERT should fail. Perhaps
that is what really happens...

Have you stepped it through the debugger?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 8 '08 #4
On Aug 8, 7:15*pm, Serge Rielau <srie...@ca.ibm .comwrote:
pompeyoc wrote:
On Aug 8, 4:13 pm, Tonkuma <tonk...@fiberb it.netwrote:
Although I felt that your description of processing logic of SP is too
general to say accurate things, I had some questions...
1) To what value was at_end initialized? And at where?
2-1) Is the loop to update the blank fields neccesary?
*Is it possible to be replaced by an UPDATE statement with something
like CASE expressions and/or appropriate WHERE conditions?
2-2) or is it possible by using expressions in the SELECT list of
first INSERT statement(witho ut using the UPDATE statement)?
INSERT INTO SESSION.TEMP_EN TRIES SELECT fields/* change these by
expressions to replace blanks */ FROM table1, table2
WHERE condition
Thanks for the immediate reply. To answer your questions:
1) The at_end variable was initialized to 0 before the DECLARE CURSOR
and DECLARE CONTINUE HANDLER statements with the command:
DECLARE at_end INT DEFAULT 0
2-1 and 2-2) Unfortunately, yes the loop is necessary because it needs
to call 2 other SP's to process the data in each row, which also means
I can't change the INSERT statement to get all the data
I'd be happy to send more info if you wish. I just took the major
parts of the program to make the message shorter.

Ar eyou sure teh variable is actually set and you do not receive a
different error.
One way fro a caller to mess with what teh callee does is to mark the
caller as READS SQL DATA. In that case your INSERT should fail. Perhaps
that is what really happens...

Have you stepped it through the debugger?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab- Hide quoted text -

- Show quoted text -
Yes. I also added INSERT commands that write messsages to a table
(sort of a debug table) and it clearly shows that the variable was set
to 1 immediately after processing the first record.

It works fine if I run it in Stored Proc Builder. I also have no
problems when I call it from a VB program in Windows or from an
ordinary COBOL program in AIX. The problem only surfaces when its a
COBOL SP that invokes it. The COBOL SP was created with MODIFIES SQL
DATA.
Aug 8 '08 #5
1) The at_end variable was initialized to 0 before the DECLARE CURSOR
and DECLARE CONTINUE HANDLER statements with the command:
DECLARE at_end INT DEFAULT 0
Just before entering the loop, is the value of at_end 0?
If yes, how did you confirmed that?
Aug 8 '08 #6
On Aug 8, 8:29 pm, Tonkuma <tonk...@fiberb it.netwrote:
1) The at_end variable was initialized to 0 before the DECLARE CURSOR
and DECLARE CONTINUE HANDLER statements with the command:
DECLARE at_end INT DEFAULT 0

Just before entering the loop, is the value of at_end 0?
If yes, how did you confirmed that?
Yes. The DECLARE at_end INT DEFAULT 0 command is placed just before
entering the loop. Also, when I run it using the Stored Proc builder,
it is set to 0 after processing the first record then set to 1 after
processing the second record
Aug 10 '08 #7

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

Similar topics

0
2473
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its last year we got traffic of between 2000 - 2500 unique visitors per day. We are now about to re-launch the site from Sweden and we need to purchase a script to run it. Having looked at what is available on the net I have realised that we need a...
6
2189
by: Robert Maas, see http://tinyurl.com/uh3t | last post by:
System login message says PHP is available, so I tried this: http://www.rawbw.com/~rem/HelloPlus/h.php It doesn't work at all. Browser just shows the source. What am I doing wrong?
0
2444
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to parse them to have a tree representation such as :
7
4392
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a few features that you'd expect in any editor, except nearly none of them seem to have: 1 - Search and repalce with Regular Expressions. 2 - Search and Replace in an Xpath context. 3 - User specified tag-generation for either on a...
8
2849
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl list class must Ioverride in order for this to work?
3
2641
by: Bob.Henkel | last post by:
I write this to tell you why we won't use postgresql even though we wish we could at a large company. Don't get me wrong I love postgresql in many ways and for many reasons , but fact is fact. If you need more detail I can be glad to prove all my points. Our goal is to make logical systems. We don't want php,perl, or c++ making all the procedure calls and having the host language to be checking for errors and handleing all the...
2
1954
by: Michael R. Pierotti | last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$") Dim m As Match = reg.Match(txtIPAddress.Text) If m.Success Then 'No need to do anything here Else MessageBox.Show("You need to enter a valid IP Address", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Hand) txtIPAddress.Focus() Return End If
8
2752
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only the sequence nos and it should be such that i can access it through the structure .plz help me .
11
4501
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
0
3967
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need Inbox Reply from Craig Somerford <uscos@2barter.net> hide details 10:25 pm (3 minutes ago)
0
10274
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...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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
9085
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...
1
7576
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
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
5469
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
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.