Consultor Eletrônico



Kbase 19362: How to get VST/Schema Table info from all connected Databases?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/03/2006
Status: Unverified

GOAL:

How to get VST/Schema Table info from all connected Databases?

FACT(s) (Environment):

Progress 8.X
Progress 9.X

CAUSE:

This requires two procedures to:
- Create the DICTDB alias (which effectively changes the Working DataBase).

- Query the databases.

The reason for the two is because the current database name is already in memory in the current procedure and cannot be changed for the scope of that procedure. The second procedure, instantiated after the procedure that creates the alias, sees the new database assigned to the DICTDB alias as the current working database.

FIX:

The _file table in the following example can be replaced with any of the available VST's and Schema Tables.

Follow these steps:

/* Procedure1.p */
DEFINE VARIABLE intVar AS INTEGER NO-UNDO.
DEFINE VARIABLE intVar2 AS INTEGER NO-UNDO.

DEFINE VARIABLE slFileNames AS CHARACTER NO-UNDO
VIEW-AS SELECTION-LIST INNER-LINES 10 INNER-CHARS 35
SCROLLBAR-VERTICAL.
DEFINE VARIABLE opFileNames AS CHARACTER NO-UNDO.

DEFINE FRAME xx slFileNames NO-LABEL WITH CENTERED THREE-D
VIEW-AS DIALOG-BOX TITLE "Available Files".

ASSIGN slFileNames:LIST-ITEMS = "".
DO intVar = 1 TO NUM-DBS:
CREATE ALIAS "DICTDB" FOR DATABASE VALUE(LDBNAME(intVar)).
RUN Procedure2.p ( OUTPUT opFileNames ).
DO intVar2 = 1 TO NUM-ENTRIES(opFileNames):
slFileNames:ADD-LAST(ENTRY(intVar2,opFileNames)).
END.
END.

DISPLAY slFileNames WITH FRAME xx.
ENABLE ALL WITH FRAME xx.
APPLY "ENTRY":U TO slFileNames IN FRAME xx.

WAIT-FOR CLOSE OF THIS-PROCEDURE.

/* Procedure2.p */
/* IMPORTANT NOTE: In version 9+, in order to avoid returning the
SQL-92 System Tables you would further qualify
the below WHERE clause with the following:
AND _File._Tbl-Type = "T". */

DEFINE OUTPUT PARAMETER opFileNames AS CHARACTER NO-UNDO.

FOR EACH dictdb._File WHERE _File._File-Number > 0 NO-LOCK:
ASSIGN opFileNames = (IF opFileNames = "":U THEN "(" +
LDBNAME("DICTDB") + ")" + _File._File-Name
ELSE
opFileNames + "," + "(" +
LDBNAME("DICTDB") + ")" +
_File._File-Name ).
END.