IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Error handling in Multi Row Fetch/Insert


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
yogi.47eie

New User


Joined: 16 Aug 2006
Posts: 45
Location: india

PostPosted: Wed Feb 19, 2014 2:58 pm
Reply with quote

Hi DB2 Experts,
In case of Multi row Fetch/Insert how the SQL error handling is done to display the problematic record in to SPOOL.Reason is, it will be having set of records with in the MRF array of columns and how will we identify the problematic record .(Ex) if its -811/-803 in our MRF fetch/Insert ,how will we display the specific problematic record among the fetched rowset ? If is singleton query we will display it directly but in case of MRF/Insert I couldn't find the proper way of displaying the error record.Any help is much appreciated.

Thanks
Yogi
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Feb 19, 2014 3:22 pm
Reply with quote

Hi Yogi,

Look at SQLERRD(3)

Thanks,
Sushanth
[Always an amature]
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Wed Feb 19, 2014 3:30 pm
Reply with quote

As you were told by sushanth, SQLERRD(3) will have

Quote:
After a successful multirow insert, update, or delete operation, this field contains the number of rows that were processed. After a multirow insert, update, or delete operation that ends with an error, this field contains the number of rows that were successfully processed before the error was detected.


This page will give you more details about SQLERRD.
http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqlt.doc/sqltmst189.htm
Back to top
View user's profile Send private message
singhju

New User


Joined: 01 Dec 2010
Posts: 25
Location: Gurgaon

PostPosted: Wed Feb 19, 2014 3:44 pm
Reply with quote

Hi,

I don't think -811 will ever occur in Multi Row Fetch as Multiple rows are fetched using a ROWSET POSITIONING cursor and cursors never fail with -811. Please correct me if this statement is wrong.
Back to top
View user's profile Send private message
yogi.47eie

New User


Joined: 16 Aug 2006
Posts: 45
Location: india

PostPosted: Wed Feb 19, 2014 5:52 pm
Reply with quote

Thanks team.. SQLERRD(3) I was using for number of rows fetched.Yes,as per your suggestion it will hold the last successful record processed.From whcih I can find the problematicc record.I wil use the same for coding purpose.
Apart from that,-811 will never occur in cursor,I realized after posting it.Thanks for your quick response team.
FYI:
SQLERRD(3)
After a successful multirow insert, update, or delete operation, this field contains the number of rows that were processed. After a multirow insert, update, or delete operation that ends with an error, this field contains the number of rows that were successfully processed before the error was detected.

Thanks
Yogi
Back to top
View user's profile Send private message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Thu Apr 03, 2014 11:50 pm
Reply with quote

Use Get diagnostic ..
Just do some Google lot of info is available
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Apr 04, 2014 10:35 am
Reply with quote

Prasun, I think TS has got what he wants more than a month back.

Quote:
Use Get diagnostic ..


It is good to have an alternative but this would add one more I/O to the process than using the existing SQLERRD(3) of SQLCA.
Back to top
View user's profile Send private message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Fri Apr 04, 2014 10:53 am
Reply with quote

Hi Rohit,
Thanks for pointing out the performance factor.. But normally whenever we use multi row fetch we put the get diagnostic in the error handling.. I have seen this is being followed in multiple site.
SQLERRD(3) will only give the number ..

Thanks
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Fri Apr 04, 2014 12:33 pm
Reply with quote

Hi,

I second Prasun for using GET DIAGNOSTIC.

But its better to use only when multi fetch statement returns sqlcode 354 considering performance factor pointed by Rohit

354 is returned when rowset FETCH statement encountered one or more warning conditions.

May be I am missing something here so GuyC or senior members inputs would be helpful

Regards,
Chandan
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Apr 04, 2014 1:48 pm
Reply with quote

Chandan, yes you are right. but not just +354 but usually GET DIAGNOSTIC is invoked in case anything apart from SQLCODE 0 or +100 comes.

So Prasun, Your are too right and usually we see them more often in Stored Procedures as to have error log updated with detailed stats.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Error while running web tool kit REXX... CLIST & REXX 5
Search our Forums:

Back to Top