INSERT INTO Session.QUERY1(
AMOUNT,
RMONTH,
RTYPE
)
SELECT SUM(X.MO_SAV_AM),X.MO_YR_DT,X.AGE_TYP_CD FROM (
SELECT c.mo_sav_am,SUBSTR(CHAR(c.mo_yr_dt),1,2)
as mo_yr_dt,
b.age_typ_cd
FROM
PWR00.PLN a, PWR00.PLN_DTL b, PWR00.MO_FIN c,
PWR00.PLN_LOB_REL d, PWR00.LOB e
WHERE
a.pln_typ_cd = l_pln_typ_cd
AND a.fin_stat_cd = 'EXCTED'
-- Cursor left open for client application
OPEN cursor1;
END P1
DB2 version is 7.1 on Mainframe.
The Stored procedure is opening a Cursor on the Declare GTB and at the end the control is passed to the Accuatre Report (which is running on the Windows Clinet side.).
After the Report is printed the Thread is not getting closed, the thread details are as under. Even after giving an Explicit Close connection from the Accuate report the thread is
not getting closed.
Because of this Active thread, when you try to run the program again it is not able to create the GTB and telling that the Session.table is already exsisting.
V445-ABB1C20E.B915.B9FB18001457=47050 ACCESSING DATA FOR
171.177.194.14
SERVER RA * 25742 erdpro.exe NBDT34P DISTSERV 00A3 2010
V437-WORKSTATION=*, USERID=nbdt34p,
APPLICATION NAME=erdpro.exe
Sreekanth Bhog... see if this makes sense
Sreekanth Bhog... SERVER RA * 25742 erdpro.exe NBDT34P DISTSERV 00A3 2010
V437-WORKSTATION=*, USERID=nbdt34p,
APPLICATION NAME=erdpro.exe
V445-ABA3DA98.J008.0F3417152701=2010 ACCESSING DATA FOR
171.163.218.152
V447--LOCATION SESSID A ST TIME
V448--171.163.218.152 446:2096 W R2 0407712183307
DISPLAY ACTIVE REPORT COMPLETE
SPs have been successfully compiled and the bind was successful as well.
I think there is some session clash between the two Stored Procs. First I am able to run both SPs individually but when I ran the report, it is giving me the following error. After that I could not run the SPs as well. The same error I am getting when I try to run the SPs as well:
PWR00.PWRSP003 - Calling stored procedure.
PWR00.PWRSP003 - The value(s) of the input parameters:
IYEAR = 2003
L_PLN_TYP_CD = SCMBNF
[IBM][CLI Driver][DB2] SQL0601N The name of the object to be created is identical to the existing name "SESSION.QUERY1" of type "TABLE". SQLSTATE=42710
PWR00.PWRSP003 - Changes rolled back.
PWR00.PWRSP003 - Done calling stored procedure.
PWR00.PWRSP006 - Calling stored procedure.
PWR00.PWRSP006 - The value(s) of the input parameters:
IYEAR = 2003
[IBM][CLI Driver][DB2] SQL0601N The name of the object to be created is identical to the existing name "SESSION.TEMP1" of type "TABLE". SQLSTATE=42710
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Mar 18, 2004 8:34 am Post subject:
Johncwl,
You can drop the Global temporary table after the report is printed by the following statement.
Code:
DROP TABLE SESSION.QUERY1;
If you want to retain rows in the temporary table instead of dropping them ,execute a COMMIT statement in the application. This deletes all the rows from the table or keeps the rows, depending on the ON COMMIT clause that you specify in the DECLARE GLOBAL TEMPORARY TABLE statement. ON COMMIT DELETE ROWS, which is the default, causes all rows to be deleted from the table at a commit point, unless there is a held cursor open on the table at the commit point. ON COMMIT PRESERVE ROWS causes the rows to remain past the commit point.
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
Posted: Thu Mar 18, 2004 9:17 am Post subject:
JOHNCWL,
We faced exactly the same problem when we were trying to call a DB2 SP from a CICS application program. The difference however was we were only getting a duplicate GTT error when we were trying to call the SP twice within the same LUW. If we ended the transaction using a CICS RETURN(I haven't tried issuing a SYNCPOINT and trying to see whether that destroys the GTT) and thus ended the unit of work, the GTT used to get destroyed. But since we needed to call the same SP repeatatively from within the same LUW, we did exactly what Kolusu has suggested. After every CALL to the SP from our appl program and after fetching from the cursor, we dropped the GTT explicitly after issuing a CLOSE cursor. That worked for our case.
If you don't want to change your client programs, another way which I think will work is that in the beginning of your SP, code a drop of the GTT and disregard the SQLCODE of -204 in case the GTT does not exist. You can try that also.
HTH.
Regards,
Manas
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
Posted: Mon Mar 22, 2004 11:57 am Post subject:
JOHNCWL, Ravi,
I agree with JOHNCWL that the GTT should be dropped as soon as the application gets over. I was suggesting the approach as a workaround and not as the solution. Perhaps you should investigate the problem further as to why the GTT is not getting dropped when the application is getting over. We faced the problem only when we were calling the SP twice from within the same LUW (that will be analogous to the same instance of your application). I am not clear as to how you are getting the problem when your application is getting over and you are calling it afresh.
Ravi -
Quote:
but the problem is it takes some time for deletion
what do you exactly mean by it takes some time for deletion. the temporary tables deletion should be a part of the same task that runs the sp.
can you explain a bit further.
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
Posted: Thu Mar 25, 2004 2:06 pm Post subject:
Ravi,
If I understand your problem correctly, then your actual problem is not the global temporary tables, but the actual connection thread between your client and the DB2 SS on the mainframe. On the ideal side, the thread should be terminated as soon as you finish running an instance of the application. The close of the thread immediately deletes the GTT (There is nothing like any time lag). But, I guess what is happening in your case is that although you finish running your application, the thread remains open (identical to JOHNCWL's problem) and hence you are getting a -204. After 10 mins, the thread times out and deletes the GTT and you can run another instance of the application.
For my case the problem was something else. A CICS-DB2 thread (defined as a DB2ENTRY) is created when you execute the first SQL in your program and remains active until the end of the task. So, if you try to access the same stored procedure from within the same task twice, it will give you a -204 on the GTT. So, in my case there was no other option but to delete the GTT explicitly.
You can maybe have a look at the reason why your connection thread is not getting terminated.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum