From the course: Oracle Database 19c: PL/SQL
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Running SQL statements: Dynamic - Oracle Database Tutorial
From the course: Oracle Database 19c: PL/SQL
Running SQL statements: Dynamic
- [Instructor] While static SQL allows a large subset of SQL statements to run Natively in PL/SQL, there are many cases where you want to run a SQL statement that's not Natively supported by PL/SQL, or you don't know exactly how the SQL statement will be constructed until runtime. Dynamic SQL comes to the rescue. Dynamic SQL is another way to run a SQL statement that can't be run Natively inside of PL/SQL, like insert, update, delete, and merge can. This includes primarily DDL statements like CREATE or DROP TABLE, GRANTING or Revoking Object or System Privileges and Truncating Tables. This category also includes Session Control Statements like Alter Session, Alter System, and Set Role. Of course, PL/SQL supports just about every variation of select statements where you can return one or many rows. But what if you don't know what columns you want to query at compile time, or even what table name you're querying or how you're going to filter rows? These queries can all be constructed at…