Re: How many records from a SELECT statement?

From: RCronau <rcronau_at_aol.com>
Date: 21 Jul 1994 22:28:09 -0400
Message-ID: <30narp$jl9_at_search01.news.aol.com>


In article <1994Jul21.074519.16041_at_pttdis.pttnwb.nl>, erwin_at_pcssdc.pttnwb.nl (Erwin Dondorp) writes:

>In several applications I need to draw a percentage bar to monitor
>the status of large SELECT statements.
>One of the applications works with a SELECT statement that is more
>or less a black box, so I cannot predict acuratelly how many
>records will be SELECTed.
>
>Does anyone know a way to acuratelly predict the number of records
>that will be selected when given a SELECT statement?
>(i.e. instead of all the data I just want COUNT(*) using the same
 >table(s), conditions, etc)
>
>One way to do it is to create a VIEW:
>
>CREATE VIEW tmp_view AS <select statement>;
>SELECT COUNT(*) FROM tmp_view;
>DROP VIEW tmp_view;
>
>Any one know a better solution?
> (preferably without creating objects in the database)

If I understand your question correctly, you have already solved the problem, but do as yet realize it.

First, I assume that you are using embedded SQL (otherwise, how would you display the progress bar). Therefore, with this assumption in mind, issue

SELECT COUNT(*) FROM <table names>
INTO :total_selected
WHERE <condition>

The total count of the records selected is then stored in the variable total_selected.

Regards,

Rick Cronau (rcronau_at_aol.com) Received on Fri Jul 22 1994 - 04:28:09 CEST

Original text of this message