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
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 |
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 |
Answer / anamika
DB2 doesnt support 'TOP' clause. Please ignore my prev
reply.
| Is This Answer Correct ? | 4 Yes | 2 No |
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 |
Answer / anju
To my knowledge, we can use fetch clause in a singleton
select inside COBOL.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / nk
Try using one of the group functions, for example, MAX or
SUM.
| Is This Answer Correct ? | 2 Yes | 4 No |
Answer / ram.g
Pass the unique key to fetch the row from the table
| Is This Answer Correct ? | 0 Yes | 3 No |
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 |
What happens in bind step in a db2 program?
Comment whether the cursor is closed during commit or not.
What are db2 error codes -305 and -407. What is the difference between these 2 error codes ?
what are the copybook changes generally we done?can anyone tell me......... Thanks in advance........
For Read Stability locks are not applicable for phantoms, What is Phantoms?
wht is d/f between union and joins ?
what is Runstats? Whem will u choose to runatats?
Can DB2 be accessed by TSO users? If yes, which command is used to invoke DB2?
can any one provide me the link for the db2 v7 & db2 v8 manual for Z/os? i need to know about the syntax of REORG in both versions & need to know the difference as well
What is the meaning of -805 SQL return code?
Hi Everyone... Under the Logical files, when am working on multiple rec format logical file, I have joined two pf's using the multiple record format logical file concept, but when i run queried the LF only the first mentioned pf records are reflecting and I am not able to see any of the field records specified under the second pf. Kindly let me know whats the reason behind this. Below is the str of LF., R rec PFILE(LOGICAA) CUSTNO CUSTNAME BILL K CUSTNO R rec1 PFILE(LOGICAA1) CUSTNO ADD K CUSTNO .....
Which command is used to connect to a database in DB2 ? Give the Syntax.