![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhklr9U1BYkCNDmzFo_5RooMYr5_vRruLP8_N2E5_GRc0vt1nOD3ipGp4hBl7gMukPtc-chuWbtsm2HiJQl6fJreATei_rgXomhXEVqQkRsPd41ar0phjk3UcejIOHg7WWLioJyTnjXY5FI/s400/condrun.png)
Since SQL*Plus has no 'If' options (outside of queries) you need a different way to conditionally call another query. One way to do that is to have a query that checks for the condition you're looking for. If it is found, &Ex_If will be set to the name of the query I wish to run. It is first undefined so we're ready for the next execution.
I use this when there are some statements I need to jump around based on conditions. In SQL*Plus, you'll need to move those statements to another query, and then insert this type of code.
My main code is Ex_If.Sql: |
---|
Undefine Ex_If |
If the condition is found, it calls RunThis.Sql |
---|
Select 'This Works!' From Dual; |
No comments:
Post a Comment