Dynamic table in a view in oracle

0

Good afternoon, friends. I need to create a view in oracle, which contains the table in the dynamic select. Example: Select * from usina2016;

This 2016 from the end of the table name, I have to get sysdate from the current year and concatenate with the plant.

Do you know how to help me?

    
asked by anonymous 16.08.2016 / 22:33

1 answer

0

The best solution is to drop drop and recreate the view, but automatic solution could be:

Create a Procedure that:

__ via execute immediate "drop" the current view

__ via execute immediate recreate the table with the new year

Create a job (schedule) that runs around 00:00 every day 01/01 and run this SP

Another solution would be:

Create a synonym for the usina2016 table, something like usinaccurente for usina2016 the view would be created over the synonym

Create a Procedure that:

__ via execute immediate "drope" the current synonym

__ via execute immediate recreate the synonym with the new year

Create a job (schedule) that runs around 00:00 every day 01/01 and run this SP

But I prefer the manual solution, recite the view "on hand"

    
06.10.2016 / 18:54