Home » SQL & PL/SQL » SQL & PL/SQL » capture IF statement
capture IF statement [message #382055] Tue, 20 January 2009 15:00 Go to next message
kkcarlton
Messages: 5
Registered: November 2005
Junior Member
Hi,

I have an if statement in a procedure within a package for which I am using variables. I would like to be able to step through the procedure with a debugger, but we have SQL Developer and I have not found a way to do that. If there is, I would like to know.

In the meantime, I am displaying the contents of the variables before I get to the if stmt in an error table. I am expecting the code of the if stmt to be executed but instead it drops to the else. Is there a way I can see what the actual IF stmt looks like that gets executed? If so, how would I capture it or look it up?

Thanks,
Kristina
Re: capture IF statement [message #382056 is a reply to message #382055] Tue, 20 January 2009 15:08 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
So we can help you & please be consistent & correct in your postings.

place DBMS_OUTPUT statements inside both branches of the IF statement.
Re: capture IF statement [message #382058 is a reply to message #382056] Tue, 20 January 2009 15:33 Go to previous messageGo to next message
kkcarlton
Messages: 5
Registered: November 2005
Junior Member
Sorry about that. We are running an Oracle 10g database version 10.1.0.4.0. That database is on a unix machine but I am not sure of the version.

What I meant by capturing the IF statement is this. My statement says:
IF lv_shpsts IN (lv_shpsts_list) THEN...


What I would like to see is how that statement is actually parsed and whether the correct information is in that statement. I don't know if what I am saying makes sense.

Is there a view maybe that shows all code that has executed or can I capture the last statement executed somehow?

Thanks,
Kristina
Re: capture IF statement [message #382064 is a reply to message #382055] Tue, 20 January 2009 17:20 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
What we have here is a failure to communicate.

>What I would like to see is how that statement is actually parsed and whether the correct information is in that statement.
With PL/SQL is parsed before it is executed.
If you open your eyes & look at the code you will see the statements.
I do not understand what you mean by "correct information"


>Is there a view maybe that shows all code that has executed
The code that is executed is what you direct to be executed.
Oracle does not automagically make up code to run.
Oracle does only what YOU give it to execute.

If you want to see the contents of certain variables,
then use DBMS_OUTPUT to print those variables.

Keep in mind that data is NOT visible to other sessions, until after a COMMIT has been issued.
So when doing DML to "save" variable values, those values may not be immediately visible to other sessions.


Re: capture IF statement [message #382068 is a reply to message #382064] Tue, 20 January 2009 18:49 Go to previous messageGo to next message
kkcarlton
Messages: 5
Registered: November 2005
Junior Member
Again, I apologize for miscommunicating. Here is what I mean.

The statement is as follows:

IF lv_shpsts IN (lv_shpsts_list) THEN


I displayed the values of those variables and lv_shpsts = S and lv_shpsts_list = C','S','L. Since they are VARCHARs I assume that Oracle is adding a single quote to the outside so that the same if statement with values should look like this:

IF 'S' IN ('C','S','L') THEN


If that were the case the code inside the IF statement should be executed, but it is not. Instead it is going to the else of that if statement so I am guessing that there is something happening I am not aware of.

[Updated on: Tue, 20 January 2009 18:50]

Report message to a moderator

Re: capture IF statement [message #382076 is a reply to message #382055] Tue, 20 January 2009 21:30 Go to previous message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

No .. It wnt work as you want .

You better refer this asktom link

Smile
Rajuvan.
Previous Topic: Query help for adding columns (merged)
Next Topic: Need Help In Query (merged 3)
Goto Forum:
  


Current Time: Sat Dec 10 16:37:06 CST 2016

Total time taken to generate the page: 0.04328 seconds