I have tables as follows in Oracle DB: abc20190101,abc20190102,etc. Each have same columns data type and same number of columns just populated with different data. I have a scheduler to run a query on these tables everyday at particular time. But table name should be appended with sysdate. Actually I need to perform only select and join operations on 2 tables like abc20190101,xyz20190101
I tried this :
select * from (select concat('abc',(SELECT to_char(sysdate-1,'yyyymmdd') from dual)) as "Table" from dual) ;
But this just returns the table name as output instead of the data values inside the table.
I have also tried this PL/SQL procedure:
declare
tabname varchar(32);
begin
tabname := 'abc'|| TO_CHAR(SYSDATE, 'YYYYMMDD');
execute immediate 'select * from '|| tabname ;
end;
But this gives syntax error. As I am new to PL/SQL stored procedures, I couldn't find where the error is. Will be helpful if someone can tell how to run select query on table name with dynamic sysdate appended to it