MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how does db2 behave?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Thu Dec 13, 2007 6:44 pm    Post subject: how does db2 behave? Reply with quote

hi,

pls suppose i am gonna execute a select cursor statement many times and that my table doesn't suffer any update/delete/insert.

are the rows retrieved ALWAYS in the same sequence?

there is no command that orders the rows, such as ORDER BY/DISTINCT/UNION/etc!

is it possible to retrieve the rows in a different sequence from one select to the other or can i be 100% sure the rows will always be read in the very same sequence?

thanks!
jc
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Dec 13, 2007 7:06 pm    Post subject: Reply with quote

jctgf,

NO you cannot sure of the same sequence of retrieval. Apart from the insert/update/delete there are other things to be considered.

1. Is it Dynamic Sql or Static Sql
2. Load utitlies like LOAD,REORG, RUNSTATS... can also affect the retrieval sequence.

Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Thu Dec 13, 2007 8:05 pm    Post subject: Reply with quote

hi,

this is a static sql.

pls, suppose there is no change in the table between one select and the next one.

no load/reorg/runstats.

assuming that, is it possible to have the rows ALWAYS retrieved in the same sequence?

thanks
Back to top
View user's profile Send private message Send e-mail
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Fri Dec 14, 2007 3:53 am    Post subject: Reply with quote

Since the ordering of the rows of an answer set of a read-only table depends solely on the access path of the program to the data and, since this is static sql, this access path does not change, I would assume, that the ordering of the rows is stabil, i.e. always the same.

There are a lot of assumptions in this statement, therefore I would simply code an ORDER BY clause and forget the bothering.

regards
Christian
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Dec 14, 2007 5:03 am    Post subject: Reply with quote

db2 simply does not guarantee same order without an order by clause. It is poor programming practice to assume that one knows enough about db2 to predict results if you do not use the appropriate syntax. If you want a predictable order, use the order by clause.


edited to correct first sentence. changed with to without. dbz
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group