Some basic progress queries.

ank123

New Member
HI,

Kindly answer me on following querier -

1) Fastet way to count the records in database table.
2) Without putting the exclusive lock can we modify the record?
3) Advantage and disadvantage of a frame, multiple frames?
4) What is META information?
5) How can we check what transactions are locked and on what tables?
6) Where is PRESELECT statement useful? Could you please explain this with an example.

Thanks in advance.
 

ank123

New Member
Hi Tom,

I am not forcing you to respond to my queries.Alos this not necesarry to respond to anybody's thread without answering the queries. :) Hope you will undersnatd this.

Regards
 
Greetings,
Basically you should try some Progress training.
These problems are NOT consistent with everyday
coding where you need pointing in the right direction.
Progress for tomorrow TODAY
 

tamhas

ProgressTalk.com Sponsor
You are likely to receive a more sympathetic response if you display some evidence of effort to solve the problem yourself. Tell us where you have looked, what you did and didn't understand about what you saw there, what you have tried, what worked or didn't work about what you tried. Just asking basic questions with no background sounds either like a lazy student trying to get someone else to do their homework for them or someone who is trying to figure out answers to interview questions for a position for which they are obviously not qualified.
 

TomBascom

Curmudgeon
Hi Tom,

I am not forcing you to respond to my queries.

Don't worry! I don't feel at all forced.

Also this not necessary to respond to anybody's thread without answering the queries. :) Hope you will understand this.

Regards

No worries! I'm just hoping that you might tell us where this company is that so badly needs help in its training department so that we might be able to assist them!

BTW -- I'm pretty sure that a bit of quality time with the search feature will find answers to each of your queries right here on this site.
 
1) Fastet way to count the records in database table.
>> you can use these simple code,
def var count# as ineger .
count# = 0 .
for each table no-lock:
count# = count# + 1.
end.
disp count# .

2)Without putting the exclusive lock can we modify the record?
you must lock a record before you want to modify it.

3) Advantage and disadvantage of a frame, multiple frames?
frames are useful in different application, so ....,I cann't express because of my bad english.

4) What is META information?
I want to know also.

5) How can we check what transactions are locked and on what tables?
commonly ,a record or table is locked , when you read a record which is locked, system will show a waring box and tell you what table and who is locking.

6) Where is PRESELECT statement useful? Could you please explain this with an example.
copy from progress manual .

To process a multi-table collection gathered by the PRESELECT option, use the last table named in the collection when you want to read the selected records. PROGRESS then automatically retrieves records from the other tables.
/* r-presl1.p */

REPEAT PRESELECT EACH order, customer OF order, EACH order-line OF order
BY order.order-date BY order.cust-num BY order-line.item-num:
FIND NEXT order-line.
DISPLAY order.order-date order.cust-num customer.name
order-line.item-num.
END.

The PRESELECT option in this example selects the logically joined record that consists of order, order-line, and customer, and makes all of these records available in the REPEAT block. Usually you perform more complex processing within the PRESELECT block.
If, within a PRESELECT block, you find a record using the ROWID of that record, PROGRESS disregards any other selection criteria you applied to the PRESELECT. For example, suppose the ROWID of order number 4 is stored in the variable ord-rowid.
DO PRESELECT EACH order WHERE order-num > 5:
FIND FIRST order WHERE ROWID(order) = ord-rowid.
DISPLAY order.
END.
In this example, PROGRESS finds and displays order number 4 even though the selection criteria specifies that the order number must be greater than 5. The ROWID always overrides other selection criteria. Furthermore, if you use FIND...WHERE ROWID(record) =..., the index cursor is not reset in the preselected list. That is, even if record ROWID(record) is in the preselected list, FIND NEXT does not find the record that follows it in the preselected list.
 

GregTomkins

Active Member
This is actually about the highest-quality question that PT has seen in months, IMHO. At least it's not just "2 + 2 = 5" garbage. So, I feel incented to answer part of it:

"META information" is information about information. In the Progress context, I would assume it to mean "meta schema", which is the DB schema that describes the application schema. This is stored in 'hidden' DB tables which generally start with a '_'.

For example, you can list all of the tables in your schema by saying 'for each _file: disp _file-name". (_file is the old Progress terminology for what we now usually call a table).

Who besides me remembers thinking how weird talking about tables used to be, and how weird talking about files seems today? I mean c'mon Progress, a file is something that Unix manages for you. Or that you hide in a cake ;)

Happy New Year, ever-shrinking Progress world !!!
 

RealHeavyDude

Well-Known Member
We all love Progress for their upwards compatibility - almost from day one, don't we? Especially for those deprecated things which - I think - won't go away ever, unless they prove me wrong.

Heavy Regards, RealHeavyDude.
 

Arnaud_

New Member
1) Fastet way to count the records in database table.
>> you can use these simple code,
def var count# as ineger .
count# = 0 .
for each table no-lock:
count# = count# + 1.
end.
disp count# .

I don't think this answer is complete.
Actually, this is the best way :
def var count# as integer.
for each table FIELDS() no-lock:
count# = count# + 1.
end.
disp count# .


:)
 

TomBascom

Curmudgeon
Actually the fastest way to count all of the records in a table is probably to run proutil dbanalys and parse the output.
 

bhargav

New Member
We all love Progress for their upwards compatibility - almost from day one, don't we? Especially for those deprecated things which - I think - won't go away ever, unless they prove me wrong.

Heavy Regards, RealHeavyDude.
I don't think this answer is complete.
Actually, this is the best way :
def var count# as integer.
for each table FIELDS() no-lock:
count# = count# + 1.
end.
disp count# .


:)
Another More Method to count the records Very Fast Is
Select Count(*) From the <table name >
 

Cringer

ProgressTalk.com Moderator
Staff member
That is not true. AFAIK your method still reads all records on the primary index in Progress.
In v11, you can do
Code:
FOR EACH <table> TABLE-SCAN:
END.
This is great if you don't care what order the records come. It doesn't use an index and is usually significantly faster.
 

TomBascom

Curmudgeon
Just for kicks:

Code:
define variable tblName  as character no-undo.
define variable areaName as character no-undo format "x(30)".
define variable rCount  as character no-undo.

update tblName.

find first _file no-lock where _file._file-name = tblName.

find _storageobject no-lock  /* we need to find the *current*  */
  where _storageobject._db-recid = _file._db-recid  /* storage area -- not the *initial*  */
  and _storageobject._object-type = 1  /* storage area that holds the table  */
  and _storageobject._object-number = _file._file-num.  /* ( _file._ianum = initial area)  */

find _area no-lock where _area._area-number = _storageobject._area-number.

areaName = _area._area-name.

display areaName.

etime(yes).

input through value( 'proutil ' + pdbname(1) + ' -C tabanalys "' + areaName + '" | grep -i ^PUB.' + tblName + ' ' ).
import ^ rCount.
input close.

display rCount etime.

pause.

etime( yes ).
select count(*) from activity.
display etime.

"activity" has about 26 million records in it.

The first time through tabanalys required 33 seconds, select took 447.
The second time through tabanalys took 8 seconds, select 140.

The "customer" table in sports2000 takes 17ms for tabanalys and 7 for select.

The upshot -- "select" is a useful quick and dirty way to count a small table but tabanalys kicks its butt on big tables.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
The performance of "select" also depends on where you use it. In a procedure editor, for example, "select count(*) from table" uses the deprecated SQL-89 interface and runs in the 4GL engine. It may be faster for counting than the equivalent ABL but as Tom said it's slow on big tables. However if you run it in a SQL client (which uses the SQL-92 engine) it performs very well in my testing.

Tabanalys churns through the data very well but if you are unfortunate to have the table in question in a very large storage area then that increases the penalty of this approach. So it's difficult to say "approach x for counting records is always best". YMMV.
 
Top