Hi all,
I'm curious if you can use a variable in a table lookup. I have 6 tables (3 production and 3 history). I want to search for a value in the database but would like to keep the coding as short as possible.
<code>
def var wk_tablename as char extent 6 format 'x(10)'.
def var fulltablename as char format 'x(10)'.
def var x as int init 0.
assign wk_tablename[1] = 'tab1_task'
wk_tablename[2] = 'tab2_task'
wk_tablename[3] = 'tabl3_task'
wk_tablename[4] = 'tab1_hist'
wk_tablename[5] = 'tab2_hist'
wk_tablename[6] = 'tabl3_hist'.
repeat:
x = x + 1.
fulltablename = wk_tablename[x].
find first fulltablename.
if available fulltablename no-lock then display fulltablename.
if x = 6 then leave.
end.
</code>
The coding I provided is not complete but I was unsure if you can lookup a database table name if that table name would be provided from a variable.
Thanks ,
Rob
I'm curious if you can use a variable in a table lookup. I have 6 tables (3 production and 3 history). I want to search for a value in the database but would like to keep the coding as short as possible.
<code>
def var wk_tablename as char extent 6 format 'x(10)'.
def var fulltablename as char format 'x(10)'.
def var x as int init 0.
assign wk_tablename[1] = 'tab1_task'
wk_tablename[2] = 'tab2_task'
wk_tablename[3] = 'tabl3_task'
wk_tablename[4] = 'tab1_hist'
wk_tablename[5] = 'tab2_hist'
wk_tablename[6] = 'tabl3_hist'.
repeat:
x = x + 1.
fulltablename = wk_tablename[x].
find first fulltablename.
if available fulltablename no-lock then display fulltablename.
if x = 6 then leave.
end.
</code>
The coding I provided is not complete but I was unsure if you can lookup a database table name if that table name would be provided from a variable.
Thanks ,
Rob