BobNoobGuy
BobNoobGuy

Reputation: 1645

progress 4gl how count the number of rows in a table

http://knowledgebase.progress.com/articles/Article/P5496

I have tried For Each tableA no-lock with i integer increment. I also tried accum. but I get no luck. The reason I think is because the table is really large.

for the accum. how can I benefit from the index if I have multiple field as the key?.

Here is the data sample.

Table name is tableA the key index is trxNum, CtrlNum, SeqNum

I tried to enter the key index this way. But I think is not a valid syntax:

FOR EACH trxCtld NO-LOCK:
  ACCUMULATE trxNum, CtrlNum, SeqNum  (COUNT).
END.

and what would be the trick to so show progress, as in how many times the loop is done. I was thinking it would be nice to show every 10000 loop to pop up a message saying "hey I have done 10000 loop" and so on...

thank you

I am guesstimating tableA has about 2 million records.

Upvotes: 1

Views: 3892

Answers (1)

Tom Bascom
Tom Bascom

Reputation: 14020

The plain and simple way:

define variable i as integer no-undo.
for each trxCtld no-lock:
  i = i + 1.
  if i modulo 1000 then display i.
end.
display i.

Something along those lines is required to show the progress. If you just want the number:

The SQL-89 way (SQL-89 is embedded in the 4GL, you shouldn't use it for anything complicated but it is occasionally handy for something quick and dirty like this:

select count(*) from trxCtld.

The dynamic query way:

define variable q as handle no-undo.

create query q.
q:forward-only = yes.
q:add-buffer( buffer trxCtld:handle ).
q:query-prepare( "preselect each site no-lock" ).
q:query-open.

display q:num-results.

Upvotes: 4

Related Questions