I have noticed that when debugging code with PL/SQL Developer, debugger hangs on stepping over certain code. The first guess was to blame that line of code, but further investigation detected nothing suspicious in it. Just simple operations inside stored procedure or call to system functions. There is clearly no reasons to hang.
Querying system views led me to finding that current SQL_CODE of debugger session is:
declare ret binary_integer; begin ret := PBSDE.DEBUG_LOOP; end;
After some time PL/SQL Developer throws an error:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
I have found related Note on Oracle Support site with exact same symptoms (Doc ID 1074885.1). But solution suggested there is either funny, or pathetic. I know that information on Oracle Support is not allowable to share, but such a thing deserves to break the rules. I will take the liberty of citing the solution part in full:
Do not run PL/SQL Developer in debug mode against an Oracle database.
Yes, that's it. So what options do I have?
Seems that you are lucky enough to come across the combination of Oracle database internal bug (technically not a bug, call it "feature" if you will) and SQL development tool you use. There are several threads on Allround Automations forum regarding this issue (i.e. this one, you can search the others by keyword PBSDE.DEBUG_LOOP), but no clear solution suggested. As usually happens Oracle blames the tool, Allround Automations blames the database.
In few words PL/SQL Developer uses system package DBMS_DEBUG and it's routines for debug purposes. The package itself is kind of obsolete (introduced in 8i version), but many IDEs still use it. The reason of hang lies somewhere inside this package and PL/SQL Developer has nothing to do with it (except not to use the package at all). Ideally Oracle should fix it but this is not likely to happen because there is more modern alternative package called DBMS_DEBUG_JDWP which serves the same purposes. Seems that the only tools that support debugging with this package are Oracle's own SQL Developer and JDeveloper (that's why there is low effort to fix the bug in obsolete code from Oracle's side).
So the alternative is to use SQL Developer or JDeveloper for debugging until PL/SQL Developer begin using DBMS_DEBUG_JDWP or Oracle fix DBMS_DEBUG. There is detailed step-by-step guide on that topic in Oracle documentation.
Occasionally, SQL Navigator loses references and doesn't debug some procedures. To correct this, you should compile the procedure where you want to debug. This doesn't mean the procedure itself is invalid.
Related
When writing PL/SQL packages I am a using Allround Automations PL/SQL Developer, not only, but also because of its handy feature of Safe Compilation, which uses a temporary compilation object.
So it allows me to just compile my code and if I have any error in my syntax, nobody would be bothered.
Some colleagues are more comfortable working with Oracle SQL Developer (cur. 19.4.0), but it happens, that they invalidate a package and jobs or other overlying layers may get affected.
I was looking at the Preferences of Oracle SQL Developer, but did not found any useful settings, while searching for comp, temp or safe. May I overlooked something.
So my question is:
Is there a way to enable Safe Compilation of packages in Oracle SQL Developer?
No, you're working with an object in a database somewhere.
My best advice is create your own, local, private instance of Oracle to do your development work. Then when you're ready to share that code with your teammates, merge your changes to Git / Compile to the official Development instance.
VirtualBox, Docker, Oracle XE - there are many, easy ways to stand up a copy of Oracle on your machine for development purposes.
Other benefits include - you now get to be your own DBA/god. If you want to debug, step into an ASH report, there's no asking, you own the instance.
I work on two projects with a lot of PL/SQL code since few months.
However, I didn't find any really interesting tools to develop on this langage.
For the moment, my configuration includes the following tools:
Eclipse (the rest of the application is developed in Java), with PL/SQL Editor plugin
As I really don't like and trust the PL/SQL Editor plugin for Eclipse, I use mainly PsPad for editing my PL/SQL files.
SQL Developer (I have also TOAD, but I don't really know/like this tool).
So what is your "perfect" toolbox for developing PL/SQL applications?
I've also read that SQL Developer 2.1 introduces a PL/SQL unit testing feature. Does anybody has a feedback about this feature and this version of SQL Developer (I still use 1.5) ?
Being an old-fashioned sort of chap I still mainly get along with SQL*Plus and the TextPad IDE. TextPad is nagware, but the licence is cheap and the tool has some fantastic features. Also people have written PLSQL syntax libraries for it, which give you keyword highlighting. It is also possible to hook TextPad into other desktop tools such as Subversion.
SQL^Developer is written in java, which means it is a voracious consumer of memory. Still there is undoubted merit in having a data browser. Also the upcoming version 2.1 features built-in unit test, which could be very tasty.
Useful utilities:
pldoc :: generate Javadoc-style
documentation from the comments in
your package spec
utplplsql :: unit test harness;
old but it still works
QUTO :: another, more
sophisticated unit test harness
(which I don't use for the same
reason I'm still hacking with
SQL*Plus and TextPad)
QGCU :: PL/SQL code generator
(previously QNXO)
In defence of Luddism
The danger with tools like TOAD and SQL*Developer is that they allow us to execute DML and DDL directly against the database, including editing PL/SQL source. This is fine and dandy and awfully in the spirit of Getting Things Done. Until we need to revert our changes. Or the production DBA demands a script....
Of course it is possible to use TOAD or SQL Developer in a safe fashion - I know SQL Developer can hook into source control as well - if just requires more self-discipline.
I always liked the PL/SQL Developer by Allround Automations - an excellent, quick and easy to use, and totally affordable tool!
For an interactive query shell - much better than SQL*Plus - I used to use "Golden" - a nice and powerful shareware tool, highly recommended.
Much better than anything else I ever tried with Oracle.
Marc
Might be a slightly different answer than you were expecting but I feel the Oracle documentation and in particular this book should be essential for any PL/SQL toolbox.
My primary editor for PL/SQL packages is SlickEdit.
SlickEdit offers good support for PL/SQL development, though you might miss the direct connection to the database that tools like TOAD or SQLDeveloper offer.
On the other hand, working on PL/SQL files (instead of directly working on database objects, like many TOAD users do) is IMO a good practice for any non-trivial project.
In addition to SlickEdit, I use a few self-made helper programs, e.g. one that loads source code from the database and creates a source file, and another one that compiles the source and calculates the correct line numbers for errors in a file that contains multible objects, e.g. both package specification and body.
For direct database access, I prefer SQLDeveloper, mostly because it's free and works well on Linux.
I use:
Eclipse as the IDE
Toby's PLSQL Editor as the PLSQL Eclipse plugin
TOAD as the database tool
utplsql and OUnit as the unit test framework
Ant as the build tool
CVS as the source control tool
pldoc as the documentation tool
CruiseControl as the continuous integration tool
Toby's PLSQL Editor can do:
Syntax highlighting
Code completion
Load to database
Header generation
F3 jump to code
I was wondering if there are any good refactoring tools for Oracle databases and especially for PL/SQL. I'm working on a project where half the developers are working with c# and the other half on the db where there is a large and complex schema and a large code base in pl/sql. We also use sql server but the database team work exclusively with Oracle.
This code base is being worked on actively and is being refactored gradually but I was quite surprised to see how bad the refactoring tools for oracle seem to be (or at least in comparison to Eclipse and Resharper).
The developers are using Toad which only has basic refactoring support (probably as its seems to be targeted more towards db admin then development). I've used Toad myself before but always had assumed for pl/sql there were more features for working with code but had never looked into it. Now as far as I can see the only refactorings that it provides are extract method (procedure) and variable renaming. I read an article comparing sql developer and pl/sql developer and these do not appear to have any better support for refactoring. I had a quick look at the eclipse data tools project but couldn't see that they've added refactoring support since I last used it (a few years ago).
For Sql Server there exists Sql Refactor which when table structures are changed gets propagated through to the stored procedures. This for me is much cleaner and less error prone than having someone manually update all stored procedures. I used an older version of these tools on a project in the past and they seemed to be quite ok but a bit slow but that was a few years ago and it was still usable.
Something similar for Oracle would already be a big help for our developement team so I'd appreciate some pointers to good refactoring tools for Oracle if they do exist.
Thanks,
Crocked
As it happens the "D" in TOAD stands Developer not DBA. In fact many DBAs anathematise TOAD and other such tools.
You are out of luck. As far as I know there are no tools for refactoring PL/SQL. The root problem is that refactoring as a concept comes from the OOP paradigm, and PL/SQL is not object oriented. It does not support inheritance or polymorphism (*). This means that many of the techniques which underpin classical refactoring practice (say as defined by Fowler) - abstraction, interfaces, etc - have no analogue in PL/SQL.
The corollary of this is that people who are used to having refactoring as part of their conceptual toolbox tend to avoid programming with PL/SQL. I once got into a heated debate on the TDD list over this. The upshot being that even developers who need and appreciated the virtues of PL/SQL would rather develop in languages with better tool support, clause #1 of the Agile Manifesto notwithstanding.
The most important tool for refactoring is automated unit testing. Although TOAD does not (I think) have integrated unit testing, the next release of Oracle SQL Developer will. There are also standalone unit test tools. I recently mentioned a couple of them in another SO thread.
In terms of refactoring PL/SQL to match changes in the database, arguably most interaction with tables ought to be underaqtken by generated table APIs rather than being embedded in transactional PL/SQL. In this happy realm there is no need for refactoring tools, we just need to re-generate the relevant APIs. The post I linked to above also mentions QCGU, a tool which can do this. Of course, when we have a PL/SQL codebase which isn't organised in such a fashion then life is harder. You won't be surprised to learn that there isn't a lot of tool support for implementing Feathers's WELC in PL/SQL.
(*) Yes, I know Oracle has Types but they are (a) SQL not PL/SQL and (b) how many people out there are actually building APIs using them?
Are there are tangible benefits in changing the PLSQL_CODE_TYPE from interpreted to native? Was wondering if there are any case studies on the same.
If benefit justifies the change, how can I go about implementing the same ?
My platform is Windows 2003 server, running Oracle 10gR2 (10.2.0.1.0) if that helps.
The benefit should be speed. Whether it is 'tangible' depends on whether PL/SQL performance is an issue for you. It won't give any benefit on the SQL side (eg SELECTing) or if you have latency issues elsewhere (eg calling web services).
Unless you are doing some computationally heavy tasks in PL/SQL, I suspect you won't notice a difference. I'd be much more concerned about running the database without the appropriate patches, so would recommend you look to applying the patchsets to get you to 10.2.0.4
Just to supplement Gary's excellent answer (which I voted up) here is some further information from the Oracle documentation
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#LNPLS01209
In addition to the excellent answers already given, unless you really need to switch to Native now, I would recommend waiting until you migrate to Oracle 11g. Here is a relevant paragraph from the documentation:
Starting with Oracle Database 11g,
PL/SQL Native Compilation does not
need a C compiler. Therefore, if you
presently use a C compiler only to
support PL/SQL Native Compilation, you
can remove it from the machine where
your database is installed (and from
each node in an Oracle RAC
configuration).
We have switched to Native compilation in our 11g database, but we don't do a lot of computationally intensive PL/SQL, so our performance gains have been almost insignificant. We hope to have code in the future that will take greater advantage of it. On the plus side it hasn't caused us any problems and was easy to do.
Is there a good tool from either Sybase or elsewhere that will enable me to debug stored procedures in Sybase ASE? I need to be able to set breakpoints & watchpoints.
Previously, in Sybase ASA (not ASE), I used Sybase Central to do this. There is a plugin for ASE, but I doubt it will let me debug procedures.
Sybase ASE comes with a command line debugger called sqldbgr. Not the most user friendly option, but it does work. You can find documentation for this in the Utility Guide.
Alternatively Embarcadero produces a SQL debugger.
You may take a look at Sybase Workspace. It's a database tool to support Sybase database servers. It comes with debug facility.
I seem to recall the Embarcadero SQL Debugger works for debugging Stored Procs in ASE. I think it is a plugin for DBArtsian. Check out their web site to get more.
Cheers,
Kevin
CAST SQL Builder (by castsoftware.com) has a debugger where you can do all the common tasks, step into, over, watch variables, select from temporary tables and so on. It's great tool, unfortunately, for home use, it costs.
Allethrin has provided the full answer.
But for this:
Alas, I need to debug some existing procedures to determine if they will break when new functionality is implemented elsewhere in the system
You certainly do not need a stored procedure debugger. Just read the stored procedure code.
The SQL editor QweryBuilder from Werysoft has a debugger for Sybase ASE: http://www.werysoft.com/
Aqua Data Studio from Aqua Fold has SQL debuggers for Sybase ASE and others (Oracle, DB2 LUW, and SQL Server).
Also, Sybase ASE ships with a command line sp debugger called sqldbgr.
Use Oracle SQL Developer. I'm presently working through a JDBC connection to a Sybase ASE database using this tool. This seems to be Eclipse-based, but is quite responsive and allows you to view source code for functions and procs too. There is also a debugger available.
To create a new Sybase connection, on the "New / Select Database Connection" window, just click on the Sybase tab, enter your hostname/port/username/password, choose a database to access, and that's it.
And this software is free of charge! One thing I love about Oracle is that they give away so many good stuff for free (think JDeveloper IDE for ADF, JRockit JVM and Mission Control, and this tool).
http://www.oracle.com/technology/products/database/sql_developer/index.html