In order to select a value / a result from a query into a variable in PL SQL, you can use the following syntax.
Source Code
1
2
3
4
5
6
7
In case you have to use dynamic sql, meaning you will have to build a query string at runtime because you do not know a table name or other parameters yet, you have to apply execute immediate ... into.
However there are some tricks to apply before it will work.
1
2
In order to escape quotes, if you have to apply an insert statement you can use q'{ ... }'.
After building a dynamic sql query string you can use execute immediate ... into in order to achieve the same as select ... ino ...