I am getting a error multiple row fetched while executing a
Cobol-DB2 program.How can I solve it without using a cursor.

Answers were Sorted based on User's Feedback



I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / marekj

I mean you want to fetch only the first row and the select
statement is correct. You have to use "fetch first 1 row
only" eg.
select name
from peoples
where name like 'A%'
fetch first 1 row only;

Is This Answer Correct ?    15 Yes 1 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / nadeem

Select statement fetches only one row from table..make sure
ur program doesn fetch multiple rows..cursor is the only
way to fetch multiple rows to my knowledge..

Is This Answer Correct ?    5 Yes 1 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / anamika

DB2 doesnt support 'TOP' clause. Please ignore my prev
reply.

Is This Answer Correct ?    4 Yes 2 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / raja mohan reddy

As of my knowledge,we cannot fetch multiple rows with out
using cursor in cobol db2, Let us see the breif explanation

When you are trying to fetch multiple rows with select
statement using perform loop it gives the result as
fetches the first row while fetching the second row program
will be end with sqlcode.

Here is the only one way to fetch multiple rows from db2
table using cobol. Please follw the following steps.

1.Declare a cursor ( we have to code SELECT statement with
our criteria)
2.Open the cursor
3.fetch the rows using cursor
4.Close the cursor

Please Let me know if you find any mis stated information

Is This Answer Correct ?    2 Yes 1 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / anju

To my knowledge, we can use fetch clause in a singleton
select inside COBOL.

Is This Answer Correct ?    0 Yes 1 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / nk

Try using one of the group functions, for example, MAX or
SUM.

Is This Answer Correct ?    2 Yes 4 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / ram.g

Pass the unique key to fetch the row from the table

Is This Answer Correct ?    0 Yes 3 No

I am getting a error multiple row fetched while executing a Cobol-DB2 program.How can I solve it w..

Answer / anamika

You cannot use 'Fetch first 1 row only' in a singleton
select in COBOL. Instead u can use 'SELECT TOP <colname>'
to get the first row in the result set.

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More DB2 Interview Questions

What is a db2 cursor?

0 Answers  


What is reorg and runstats in db2?

0 Answers  


Hi i need to write a query on the following requirement. SELECT COMM_TEXT INTO :WS_MIKM_COMM_TEXT FROM MPIPROD.MIKMV01 WHERE ACCOUNT_NO = :WFD_ACCOUNT_NO AND (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC) OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT) The above query is to be modified. The requirement is if both the fields are equal then that has to be given priority. In the above query if it satisfies any one it comes out without checking if both being equal is possible.

1 Answers  


What technique is used to retrieve data from more than one table in a single SQL statement?

9 Answers   CTS, IBM, TCS,


B37 abend during spufi?

0 Answers   IBM,


How can deadlocks be resolved?

0 Answers  


What if we fail to give values in columns declared as NOT NULL ?

3 Answers   Cap Gemini,


Explain various types of locks in db2?

0 Answers  


What is a root page?

1 Answers  


why should we bind the DB2 program . What if we did not BIND a BD2 program ??

9 Answers   Infosys, TCS, Xansa,


what's the best lock size that you could use when you create a tablespace?

2 Answers   IBM,


i have an employment table whch has salary,dept,name? i want salary b/w 1000 to 5000 can anyone pls say the query for ths ?

8 Answers   Cap Gemini, CGI, EDS, IBM, Satyam, Wipro,


Categories