Dynamic buffers

brado

New Member
I want to be able to do something like:

IF condition TRUE THEN
DEF BUFFER buf FOR sports.product.
ELSE
DEF BUFFER buf FOR newsports.product.

What is the exact progress commands to enable me create a dynamic buffer based on some condition i.e. to have the buffer buf pointing to either of the 2 DBs depending on the condition.
 
To do this truely dynamic try something like:
Code:
DEF VAR lhBuffer AS HANDLE NO-UNDO.
DEF VAR lvTable AS CHAR NO-UNDO.

IF condition
THEN lvTable = "First Table Name":U.
ELSE lvTable = "Second Table Name":U.

CREATE BUFFER lhBuffer FOR TABLE lvTable.
With the above you willhave to use dynamic queries etc to access the buffer. Alternatively youcan create an alias for the databases and switch the alias based on thecondition. That way you can create the buffer for the aliased databasetable and use "normal" 4gl statements to access the buffer.
 
Thanks for that.

The second option would suit me better, how would I go about switching between the aliases and creating the buffers for the selected alias.
 
Back
Top