Hello, you are not logged in.  Login or sign up
Community >> Blogs
Search Toad World Search

Do you have a topic that you'd like discussed?  We'd love to hear from you.  Send us your idea for a blog topic.

Toad for Oracle 9.0 - How do I Debug PL/SQL Combined into a Single File?
 
Location: Blogs John Pocknell    
 JohnPocknell Tuesday, April 24, 2007 1:24 PM
In this short blog, I want to cover a topic which quite a few customers have asked me about over the years, and that is where they need to debug a Package where the Package Specification and Package Body is stored on their file system as a combined file.

Toad’s Editor is designed to make developing Packages, Types, Procedures and Functions easy. In Oracle, the Spec and Body of a Package or Type are two separate objects, although they work together. Since the Editor is not a script editor or processor, multiple objects are maintained in separate tabs: one tab per object.

Maintaining one object per tab allows Toad to provide advanced features such as interactive debugging, Team Coding, and advanced parsing capabilities.

Keeping objects on individual tabs makes it easy to jump from the Spec to the Body, simply by pressing and clicking over an object name.

However, some developers prefer to save both the Spec and the Body of a Package in one file. Toad can accommodate this using its file splitting options.

File splitting in Toad for Oracle was specifically designed to accommodate users with multiple PL/SQL objects in a single file. This feature lets you load multiple objects from one file and save Package Specs and Bodies to one file.

When a file is loaded, the Editor checks to see whether more than one PL/SQL object is created in the file, if so, the Editor takes action depending upon which of the options listed below is set.

Go to Options | Editor | Open/Save.

Automatically split files when multiple objects separated by "/"

This option will automatically split files when Toad comes across a "/". Toad assumes you want to split different objects onto different tabs.

Each section divided by a forward slash will be placed in a separate tab.

Prompt to split files

When this option is checked, Toad will ask if you want to split a file into separate tabs. Splitting the file is recommended, but you can choose at the prompt to keep the file as one.

Note: If you do not split the file, compiling will be disabled.

Never split files

When this option is checked, Toad will always load files into one tab and never split a file into body and spec. Note: This option disables compiling.

In addition, you can decide how you want the Package to be displayed in the Editor. For example, if you choose to load the Package into a single tab in the Editor, you will be able to compile and debug the Package the same as you would if you loaded them into separate tabs. But, in any case, you have to begin your debugging session in the Body otherwise the debugging buttons will be greyed out…..

If you are using (and want to watch) Package variables, you must tell the Debugger what type of variable it is

After you have added a Watch to the variable, double-click in the Watches tab to open its properties. Click the Package Variable check box and select the Package name and Owner from the drop downs. You can also define the format of the values expressed (Floating Point, Scientific, etc). As you debug, you will be able to track the values of the Package variable as it changes. Note the Break on value change.

Also, make sure you have the below options set and that you have the DBMS Debugger option set (not JDWP). Options | Debugging.

The other option you should set is the “Step through package initialization”.

When you have a Package that includes Package variables, the first time you execute a Procedure in the Package the variables are initialized. If this option is checked, the Debugger will step to the lines of code where the variables are declared and initialized. If the option is unchecked, the Debugger will never step into the Package initialization.

Debugging Packages in Toad is a breeze, but if you are new to this, there is a very simple example Package available in the Toad Help called Trigonometry which you can install and use as a test (Help | Index | keyword Package).

Once you’ve completed your debugging session, the code will have to be re-combined back into a file. Again, refer to the Options under “Saving files” to decide how you want this done.

 

When a Package Spec and Body are both loaded from database into the Editor, and you choose to save to file, Toad’s behavior depends on these options.

If only the Spec or only the Body is loaded, then only the object that is loaded will be saved to file.

The default is Never combine spec/body. 

Automatically combine spec/body when saving object to file

Puts Spec and Body into the same file. 

Prompt to combine spec/body

Prompts you every time you close the files.  

Never combine spec/body

Saves only the object on the current tab.

Copyright ©2007 Quest Software
Permalink |  Trackback

Comments (3)   Add Comment
By TOAD4Oracle on Wednesday, April 25, 2007 12:15 PM
If we decide to purchase TOAD for Oracle for our work application, please provide information about the best package and price you can offer.

By TOAD4Oracle on Wednesday, April 25, 2007 12:16 PM
jc3245@att.com is my email address.

Eugene Cao

By Pockers on Wednesday, April 25, 2007 1:04 PM
Thank you for your enquiry Eugene. I will respond to your email.

John


Comment:
Add Comment   Cancel 
Search Blog Entries
 
Copyright 2008 by Quest Software  | Terms Of Use | Privacy Statement | Contact Us