Consultor Eletrônico



Kbase P17103: How to access the correct metaschema information when multiple databases are connected?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/15/2009
Status: Verified

GOAL:

How to access the correct metaschema information when multiple databases are connected?

FACT(s) (Environment):

Progress 9.x
All Supported Operating Systems
OpenEdge 10.x

FIX:

Use dynamic database objects to access metaschema information when multiple databases are connected (and switching the 'working database' is not an option).

For example, to find the _File record for a table named 'Customer' without knowing what database that table exists within, do the following:

DEFINE VARIABLE cTable AS CHARACTER NO-UNDO INITIAL 'Customer'.
DEFINE VARIABLE cFullTable AS CHARACTER NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.

CREATE QUERY hQuery.

DO iLoop = 1 TO NUM-DBS:
ASSIGN cFullTable = LDBNAME(iLoop) + '._File'.

CREATE BUFFER hBuffer FOR TABLE cFullTable.

hQuery:SET-BUFFERS(hBuffer).
hQuery:QUERY-PREPARE('FOR EACH ' + cFullTable + ' NO-LOCK WHERE ' + cFullTable + '._File-Name = "' + cTable + '"').
hQuery:QUERY-OPEN().
hQuery:GET-FIRST().

IF hBuffer:AVAILABLE = TRUE THEN
DO:
/* Code Goes Here To Do Some Processing When The Record Is Found */
END.

hQuery:QUERY-CLOSE().
DELETE OBJECT hBuffer NO-ERROR.
END.

DELETE OBJECT hQuery NO-ERROR.