If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 table Browse (embedded)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-04, 05:07
Bijay Bijay is offline
Registered User
 
Join Date: Dec 2004
Location: Bangalore, India
Posts: 2
DB2 table Browse (embedded)

Hi,

Recently, I was coding for a DB2 table browse program, say 5 rows per screen, but was not able to form a logic to load only 5 rows at a time in a cursor, that is, everytime for example, the program executes this SQL for a cursor while scrolling down:

SELECT EMPNO,ENAME,EDEPT,ESAL FROM EMP WHERE EMPNO > ?

'?' will replace the last EMPNO displayed in the 5th row of the screen.

Can anyone tell me whether such a query which loads more of rows than required in a cursor (to my opinion) is efficient enough ? Is there a better query (considering all insertion or deletion that can take place in between parallely in the same table) ?
Reply With Quote
  #2 (permalink)  
Old 12-10-04, 06:49
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
scrolling

if using select * from table where empno > xx order by
it will get all rows > xx and srt these rows
it happens at open cursor
do : select * from table where empno> xx fetch first 5 rows only
be carefull to use also isolation level cs (or ur if no harm)
hope this will help
Best Regards, Guy Przytula
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
Reply With Quote
  #3 (permalink)  
Old 12-11-04, 01:01
Bijay Bijay is offline
Registered User
 
Join Date: Dec 2004
Location: Bangalore, India
Posts: 2
DB2 Table browsing (embedded)

Quote:
Originally Posted by przytula
if using select * from table where empno > xx order by
it will get all rows > xx and srt these rows
it happens at open cursor
do : select * from table where empno> xx fetch first 5 rows only
be carefull to use also isolation level cs (or ur if no harm)
hope this will help
Best Regards, Guy Przytula
Hi Guy,

Thanks.
But you have completed my query:

"select empno,ename,edept,esal from emp where empno > ? order by empno"

will fetch all the rows after '?', but what I want is the cursor should only contain next 5 records (since I am using 5 rows per screen), therefore, any time, cursor should contain only 5 or less records.

Further, I still doubt whether this is required or not? Whether this will improve the performance?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On