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

How to fix SQLCODE -811?


IBM Mainframe Forums -> ABENDS & Debugging
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
madlui56

New User


Joined: 08 Aug 2006
Posts: 61
Location: Philippines

PostPosted: Tue Jun 26, 2007 12:28 pm
Reply with quote

What does this mean SQLCODE -811 and solution for this?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Jun 26, 2007 12:39 pm
Reply with quote

Hi There,

It means that u try to insert a row which is voilating unique index clause

Code:
-811 THE RESULT OF AN EMBEDDED SELECT STATEMENT OR A SUBSELECT IN THE     
       SET CLAUSE OF AN UPDATE STATEMENT IS A TABLE OF MORE THAN ONE ROW,
       OR THE RESULT OF A SUBQUERY OF A BASIC PREDICATE IS MORE THAN ONE 
       VALUE   


Please download abend assist from the site
Back to top
View user's profile Send private message
ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Tue Jun 26, 2007 1:29 pm
Reply with quote

Hi,
you can even get -811 in an embedded SQL SELECT, if your query returns more than one row. The description is as follows.

Execution of an embedded SELECT statement has resulted in a result table containing more than one row. Alternatively, a subquery contained in a basic predicate has produced more than one value.

--Parag
Back to top
View user's profile Send private message
edsellouie

New User


Joined: 13 Sep 2007
Posts: 1
Location: toronto

PostPosted: Sat Sep 15, 2007 1:47 am
Reply with quote

In your application, you may have to declare a CURSOR to resolve this issue. If you're expecting more than 1 row during a SELECT, then you need to have a CURSOR declared before you FETCH each record until there are no more records.

If you don't expect more than one row, then you have to make sure your WHERE clause would retrieve unique records from the specified columns.

...hope this helps...
Back to top
View user's profile Send private message
senthilssg

New User


Joined: 09 Dec 2005
Posts: 64
Location: USA

PostPosted: Tue Sep 25, 2007 8:03 pm
Reply with quote

Hi ,

If you want only row , you can use FETCH FIRST ROW ONLY to your Query , so that you can avoid -811 also reduce the CPU cost by avoiding of unncessary rows were fetched from table .

Code:
Eg :

Select column1 , column2
From tablename
where column3 = 'value'
Fetch first  row only
Back to top
View user's profile Send private message
Raghavendra P K

New User


Joined: 24 Aug 2007
Posts: 24
Location: bangalore

PostPosted: Tue Oct 23, 2007 4:37 pm
Reply with quote

Hi ,

Change your where clause to fetch the records based on the Primary key.This will not give you -811 error. If you read a table based on the primary key you will not get multiple records.
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 -> ABENDS & Debugging

 


Similar Topics
Topic Forum Replies
No new posts SQLCODE = -122 while using the scalar... DB2 4
No new posts SQLCODE = -16002 when using XMLEXISTS DB2 1
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts SQLCODE=-204 SQLSTATE=42704 DB2 4
No new posts Getting sqlcode 805 while executing R... DB2 10
Search our Forums:

Back to Top