Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using Variable tab name for a select

Former Member
0 Likes
722

Hi,

I need to do a select from a two different tables controled by system date.

I try to do the following for example:

Data: tabela type tabname.

if l_data ge '01012009'

tabela = 'zxx_new'

else.

tabela = 'zxx_old'

endif.

Select * from tabela

where ...

It's possible using Select statement this way ? or i need to do...

if l_data ge '01012009'

select * from zxx_new ...

else.

select * from zxx_old ...

endif.

Thanks,

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
494

Almost ok, should be:


if l_data ge '01012009'
tabela = 'zxx_new'
else.
tabela = 'zxx_old'
endif.

Select * from (tabela)   "here you determine table dynamicaly  by giving its name
where ...

Regards

Marcin

1 REPLY 1
Read only

MarcinPciak
Active Contributor
0 Likes
495

Almost ok, should be:


if l_data ge '01012009'
tabela = 'zxx_new'
else.
tabela = 'zxx_old'
endif.

Select * from (tabela)   "here you determine table dynamicaly  by giving its name
where ...

Regards

Marcin