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 > Last select count

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-01-04, 08:26
ApoPen ApoPen is offline
Registered User
 
Join Date: Jul 2004
Location: Ottawa, Canada
Posts: 58
Last select count

Is there a function in DB2 to get the count from the last select.

example...

db2> select var1,var3,var3,var4 from mytable where var5='test' fetch first 10 rows only;

db2> function to get last select count without fetch count.


The reason I'm asking this is that i'm migrating from mysql and they have a function to do this.



"A SELECT statement may include a LIMIT clause to restrict the number of rows the server returns to the client. In some cases, it is desirable to know how many rows the statement would have returned without the LIMIT, but without running the statement again. To get this row count, include a SQL_CALC_FOUND_ROWS option in the SELECT statement, then invoke FOUND_ROWS() afterward:

mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name" WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();
Reply With Quote
  #2 (permalink)  
Old 09-01-04, 09:06
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You did not state which version of DB2 or OS, I will assume you are using 8.1 for LUW.

There is no function like that as far as I know.

Andy
Reply With Quote
  #3 (permalink)  
Old 09-01-04, 10:44
n_i n_i is online now
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
See if GET DIAGNOSTICS ... ROW_COUNT will help you
Reply With Quote
  #4 (permalink)  
Old 09-01-04, 11:01
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
GET DIAGNOSTICS is only valid in Stored Procedures.

Andy
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