• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to troubleshoot PL/SQL block that contains WITH clauses?

Resolved: How to troubleshoot PL/SQL block that contains WITH clauses?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

My workflow follows: I developed some SQL statements according to a certain logic. Then I am asked to bundle the SQL statement into PL/SQL block to help trigger/schedule the execution of said statements. At that point, I can see that PL/SQL block (despite being copy/paste of the SQL statement + passing argument) does not give the same results.
While I can DBMS_OUTPUT.PUT_LINE the arguments to check they are what was intended, I did not find a way to peek into what happens in the WITH clause of the SELECT statement. I tried SELECT INTO a local variable of the PL/SQL block, but it is not allowed to do SELECT INTO if not at the outer-most SELECT (which is never going to be the case in an element of a WITH clause).
So the question is how to troubleshoot this type of statement?
I don’t have an MRE, I am looking for a general solution to change my workflow rather than a workaround for this case.
Note: I am fine with a high-level answer so long I could practically use it. (for instance: “never use WITH clause in PL/SQL” would be fine). Note: I say “troubleshoot”, because I can’t debug as the DBA didn’t grant debug rights, and ETA to get debug rights granted is more than 12 months away.

Answer:

If you want to see what is going on with a WITH clause such as:
and you want to see what is going on in the first sub-query factoring clause then just repeat the SQL statement and stop after the first clause:
And you will see what is going on.

Then I am asked to bundle the SQL statement into PL/SQL block … how to troubleshoot this type of statement?


Do exactly the same thing but wrap it in a cursor or use BULK COLLECT INTO and then loop through the cursor or collection and print the rows with DBMS_OUTPUT.
db<>fiddle here

If you have better answer, please add a comment about this, thank you!

oracle oracle19c
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why when i change manualy the url on my react page it ignores the .css file?

24/03/2023

Resolved: navigate and redirect not redirecting to path in react router

24/03/2023

Resolved: Time Complexity: Find the number of people who know a secret leetcode 2327

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.