Need a clarification on -811

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Need a clarification on -811

Post by Gurugars » Wed Dec 26, 2012 11:21 pm

Friends -

I need a clarification on sql -811.

When I get -811 error in DB2, will my host variable have the first records value or not?

Many Thanks in advance..!!

Guru.
Guru:-)

You're never fully dressed without a smile :)

User avatar
Vamsi99
Active Member
Posts: 183
Joined: Wed Nov 05, 2008 11:20 am

Post by Vamsi99 » Thu Dec 27, 2012 2:41 am

Yes. Varaibles will have first record details. sql code -811 only tell us that, there more rows, need to use cursor instead of singleton sql query.

chaat
Member
Posts: 20
Joined: Sun Apr 18, 2010 11:51 pm
Location: St. Cloud, Minnesota, USA

Post by chaat » Sun Dec 30, 2012 8:29 am

Guru,

if you only need the data from the first row which meets your criteria, then add a "FETCH FIRST ONE ROW ONLY" to the bottom of your select statement as it will execute faster.

hint --> this causes DB2 to quit searching once it finds a row which meets your criteria, so you will never get a -811 sqlcode and you won't know if there are multiple rows which meet your condition.

so it depends on what your objectives are for this SQL statement.

Chuck H.
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Mon Dec 31, 2012 12:42 am

Thanks Vamsi & Chuck!

Chuck -

we had some db2 performance issue in one program, so we were asked to remove the FETCH FIRST ROW ONLY and handle -811.
But when thinking of doing that in cursor I had this doubt.

Thanks again!!
Guru:-)

You're never fully dressed without a smile :)

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon Dec 31, 2012 10:10 pm

so we were asked to remove the FETCH FIRST ROW ONLY and handle -811
Who requested this and why?
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others