If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > error while selecting

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-29-10, 17:57
surjyakp surjyakp is offline
Registered User
 
Join Date: Jan 2010
Posts: 26
error while selecting

Hi
I am executing below stmts inside a procedure
DECLARE USRID INTEGER;
SET USRID=(select usrid from pq5.incdnt_all where INCDNT_ID=Incdnt_ID);

But it is throwing below error
Value of output parameters
--------------------------
Parameter Name : SQL_ERROR_CD
Parameter Value : -811

Parameter Name : APP_ERROR_CD
Parameter Value : 500

incdnt_is is the primary key of the table.

Plz help me resolve this issue.

Thanks
Surjya
Reply With Quote
  #2 (permalink)  
Old 01-29-10, 18:18
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
the -811 states that the select statement is returning more than one row. You need to alter your select conditions so that you only get a single row returned.
Dave Nance
Reply With Quote
  #3 (permalink)  
Old 01-29-10, 19:27
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
INCDNT_ID=Incdnt_ID
From where came INCDNT_ID and Incdnt_ID?
DB2 is not case sensitive.
So, both might be considered column of table pq5.incdnt_all.

Add prefix with table name and your procedure name, like this...
incdnt_all.INCDNT_ID = procedure-name.Incdnt_ID

Or, correct the names.
Reply With Quote
  #4 (permalink)  
Old 01-29-10, 20:19
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Another consideration is where do you use USRID?

If it is used in where clause in another select statement(or cursor), it might be worth to consider to include the scalar-subselect into the select statement(or cursor).
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On