|
View previous topic :: View next topic
|
| Author |
Message |
G1NXU6T
New User

Joined: 22 Jun 2009 Posts: 11 Location: India
|
|
|
|
hi
When in a program an open cursor commands gets executed, I know that the SQL in the cursor gets executed and a resultant table will be created, cursor is placed at the first row and rows are ready for fetch.
But what will happen to open cursor when we have ORDER by clause involved in the SQL statement.
My second question is
IS it always rule of thumb that the SQL in the cursor gets executed and the resultant table is produce at the time of opening of cursor or do we have exceptions.
Could someone please help me with this.
Many thanks |
|
| Back to top |
|
 |
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
the answer to the second question is NO.
Sometimes (almost) nothing is done when a cursor is opened (1)
Sometimes the sql is executed and a temporary result table is built. (2)
The question is : when (1) and when (2).
The answer is : check the accesspath, when it contains a work table is it is (2).
Often but not always, when you use ORDER BY , a work table is needed. Sometimes even without ORDER BY, a work table is used.
That's the best answer I can give without a full course of accesspaths and optimizer decisions. |
|
| Back to top |
|
 |
G1NXU6T
New User

Joined: 22 Jun 2009 Posts: 11 Location: India
|
|
|
|
thanks GuyC.
But how can I check in the access path weather work table is created or not.
Which field will give me this value.
Thanks.[/quote] |
|
| Back to top |
|
 |
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
It's not just one field that would tell you.
A few possibilities
- if there is a sort step in the plan_table
- if there is list prefetching
-... |
|
| Back to top |
|
 |
|
|