How can I calculate the total number of records using Progress 4GL

How can I calculate the total number. records in the table? I want to show all table names in DB along with no. records in each table

+3
source share
4 answers

The way you get the number of records depends on the application you are planning.

Our database administrators just use utilities. In Unix / usr / dlc / bin / proutil -C dbanalys or some options for obtaining database information and just dump to a file.

To get schema information from progress itself, you can use VST tables. In particular, in a particular database, you can use the _file table to retrieve all table names.

, . - .

.

, - .

CREATE WIDGET-POOL.

DEF VAR h_predicate AS CHAR     NO-UNDO.
DEF VAR h_qry       AS HANDLE   NO-UNDO.
DEF VAR h_buffer    AS HANDLE   NO-UNDO.

FOR EACH _file NO-LOCK:

    h_predicate = "PRESELECT EACH " + _file._file-name + " NO-LOCK".

    CREATE BUFFER h_buffer FOR TABLE _file._file-name .
    CREATE QUERY h_qry.
    h_qry:SET-BUFFERS( h_buffer ).
    h_qry:QUERY-PREPARE( h_predicate ).
    h_qry:QUERY-OPEN().

    DISP _file._file-name h_qry:NUM-RESULTS.

    DELETE OBJECT h_qry.
    DELETE OBJECT h_buffer.

END.
+5

:

proutil dbname -C tabanalys > dbname.tab

, db.

, , , .

+5

Easy:

Select count(*) from tablename.

A bit trickier:

Def var i as int.
for each table:
    i = i + 1.
end.
display i.

For a more complex answer, you have the rest.

+1
source

Use the CURRENT-RESULT-ROWfunction with DEFINE QUERYand GET LASTto get the total number of entries:

eg.

DEFINE QUERY qCustomer FOR Customer SCROLLING.
OPEN QUERY qCustomer FOR EACH Customer NO-LOCK.

GET LAST qCustomer.
DISPLAY CURRENT-RESULT-ROW("qCustomer") LABEL "Total number of rows".
...
CLOSE QUERY qCustomer.
-1
source

Source: https://habr.com/ru/post/1715696/


All Articles