Can you use a select query in a loop to fetch multiple rows?
If so what is the advantage of using a cursor?
Answers were Sorted based on User's Feedback
No. In cobol-db2 program, the result of single select should be only one row.
For multi row fetch we must use cursor, else program will abend with -811 sql code.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / satheesh reddi
no...for that we are using cursors. due to cursors we can retrieve or fetch number of rows at a time from the table
| Is This Answer Correct ? | 0 Yes | 0 No |
what is difference between Plan and Package
What is a db2 collection?
Is it possible to update a primary key value? If not, what is the error code given? If yes, can more than 1 primary key column be updated at a time?
How can you classify the locks in db2?
if any of the column names is provided wrong, where do you get the error(during precompilation or during Bind)
SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.
Why cursor is used in db2?
what is plan? is plan executable or package?
What is difference between rollback and commit?
in db2, already 10 columns arie der, and i want to insert 11th column. what parameters u wil consider for insertion and how will u insert
What's the difference between DB2 active log and archive log? Thanks a lot...
How do you select a row using indexes in db2?