Consultor Eletrônico



Kbase P28716: How to refer to a table name dynamically?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   24/01/2005
Status: Unverified

GOAL:

How to refer to a table name dynamically?

GOAL:

Can a field be modified when the name of the table is not known until runtime?

GOAL:

How to modify a record when not knowing the name of the table and of the field until runtime.

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x

FIX:

Use a code like this: DEFINE VARIABLE htab AS widget-HANDLE.
DEFINE VARIABLE fhc AS HANDLE.
DEFINE VARIABLE cTableName AS CHARACTER INITIAL "customer" NO-UNDO.
DEFINE VARIABLE cField AS CHARACTER INITIAL "city" NO-UNDO.
DEFINE VARIABLE myNewValue AS CHARACTER INITIAL "Palermo" NO-UNDO.
/* Note that we have stored name of the table
and name of the field in char vars */
CREATE BUFFER htab FOR TABLE cTableName.
DO TRANSACTION:
htab:FIND-FIRST().
fhc = htab:BUFFER-FIELD(cField).
MESSAGE "Name of" cField "field is: " fhc:BUFFER-VALUE SKIP
"data type :" fhc:DATA-TYPE .
fhc:BUFFER-VALUE = myNewValue.
MESSAGE "After change, Name of" cField "
field is: "fhc:BUFFER-VALUE.
END.