Dynamic View: In Today’s world Dynamic SQL is the key aspect for every developer. Sooner or later developers always get requirement to write dynamic SQL. Dynamic SQL is a programming technique that enables you to build SQL statements dynamically at runtime. You can create more general purpose, flexible applications by using dynamic SQL because the full text of a SQL statement may be unknown at compilation
As you know yesterday we have created one target table i.e. Employee_Target with use of SPLIT and FLATTEN function and now we will create a VIEW over this table Dynamically.
To be more flexible we will pass the name of table and a view would be created automatically. A View name would be start as “Dynamic_View” and appended with the table name pass at the time of calling the procedure.
Inorder to call the procedure use the below syntax:
This would provide an automated way to create the view based on the Table name passed to the procedure.
Now we can query the View: