when does the SQL statement gets executed when you use
cursor in the application programming ?
Answers were Sorted based on User's Feedback
Answer / mna
The process of using cursor is:
1. declare the cursor in working storage: You will write
the SQL query here
2. open the declared cursor : this is when the actual SQL
query is executed and the fetched rows are moved to the
cursor storage.
3. Fetch rows from cursor : Reading rows one by one on the
Cursor just like we read records from a sequential file
4. Close cursor : While fetching if we get an SQLCODE=+100
it is the end of the cursor just like we encounter eof
while reading records from a sequential file. Once this
condition is encountered we will close the cursor.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / m4io
It depends
If the cursor needs materialization then it gets executed
on "open cursor" like answer 1 and 2 say.
else
the query for the next row gets executed on each fetch.
Materialization happens f.e. when sorts are used.
You can close a cursor without having sqlcode +100.
Suppose a cics transaction reads a table (1.000.000 rows)
via an index : if only 20 rows are needed it will only
request 20 rows (1 each fetch) and then close the cursor.
In batch : if I get 100 pens and need to distribute them to
the people who requested some in order of date-requested, I
will close cursor as soon as 100 pens are distributed.
| Is This Answer Correct ? | 1 Yes | 1 No |
If a non-DB2 program calls a DB2 program, the calling program's name will be there in SYSIN of IKJEFT01 and the plan name will be that of the called program. But is a bind needed or a plan has to be created for the non-DB2 program also?
In SPUFI suppose you want to select maximum of 1000 rows, but the select returns only 200 rows. What are the 2 SQLCODEs that are returned?
Can you tell me how can you find out the # of rows updated after an update statement?
how to copy the host variables from ps file into cobol program other than include statement
i want to know how the commit option works,how it save the changes? it will update the database or what ? where we can see these saved changes?
What is db2 and what is the use of db2 optimizer?
What are the rules for db2 programming?
What is DCLGEN ?
What is read-only cursor?
Is it possible to alter a table – for example adding a column, when another user is accessing or updating some columns?
Explain about cursor stability?
What is lock escalation in db2?