Record Count!!

Hi Everybody,

I need to count the total number of records in a table...
Do we have any specific function to get the count, or else we have to iterate through the entire table for record count using FOR-EACH stmt...

Can anyone give me the best usage of this... Plzzz take performance in to considerations... :confused:


Thank u in advance.....
 
There is no function or VST to get the count of records in a table.

Do a
select count(*) from tablename

or For each...

Although depending upon your configuration (client/server etc)
peformance of FOR EACH can be optimized for counting.
Like :
FOR EACH customer FIELD() NO-LOCK:
Should give better performance (Just for counting).

-Parul.
 
Ya, thank u...
But u should remember one thing it is basically an SQL Query na, its working in Progress but u may get some problem with usage of index na???

I am not sure, but if u can give me some idea on that, i wil be very happy....;)

Thanks a lot...
 
There is no way to count records in the 4GL without iterating through them.

The 4GL engine always uses an index (except for single record fetches by ROWID or RECID).

SQL statements embedded within 4GL are SQL-89 and they use the 4GL query engine. They are also deprecated.

The SQL-92 engine is external to the 4GL (it's what ODBC et al use) and is capable of a query that uses no indexes. This is said to be much faster for purposes such as counting records.

Some people also find it useful to shell out to the OS and run "proutil dbname -C tabanalys" (with an optional storage area name) in order to obtain a record count (and possibly cache it). Depending on why you need the count and upon how accurate it needs to be this is sometimes a very effective approach.
 
Thanks a lot...
Is it advisable in using SQL Query stmts in Progress??? :confused:
U have said that SQL embedded with Progress is deprecated...

So hope so its a worst idea for going to some stmts like,
select count(*) from <table name>
in Progress...

Am i right????
 
SQL-89 is deprecated. Using SQL statements from inside the 4GL is not recommended. It is very unlikely that they will actually be removed from the language (that would change if I was in charge :rolleyes:) but if there are any bugs they won't get fixed. Furthermore mixing the SQL data access model and the 4GL way of doing things is just plain confusing.

In other words... it is a bad idea to use SQL inside 4GL. Don't do it.
 
Back
Top