Is there a way to safely compile packages in Oracle SQL Developer - oracle

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.

Related

How to Mimic SQL Developer Database Copy Feature Behavior Through Scripting

SQL Developer has a feature "Database Copy". I had initially thought that maybe it uses SQL*Plus COPY Command under the hood. However, this doesn't appear to be the case, as you can copy CLOB's through the SQL Developer option. Any ideas on what it uses, and how one could possibly script out a copy using the same methods? I find the feature to work really well when compared to some other database development IDEs for copying data.

PL/SQL developer: debugging hangs on certain code

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.

"Faking" an Oracle Database

The QA department that tests my apps at work uses an Oracle database that they all share. Things get really hairy w/ their cases getting changed. bug reported filed + I spend time just to find out the test case has been changed = time wasted.
What I'd like is for dev and qa to all have our own copy of Oracle running on our machines, so we can protect our data and chase our tails... less.
The problem, which I understand, is we don't have funding for all those licenses. Using an open source database won't work because we have all kinds of PL/SQL packages and triggers that I'm sure tie us to Oracle.
Does anyone know of a way (or maybe an open source product) to "fake" an Oracle database? There are no performance requirements at all. I don't mean mocking objects (we do use that for unit testing), but the actual "listening on a port for your request" RDMS. It's a longshot, but I have to ask.
Use Oracle Express for this purpose.
http://www.oracle.com/technetwork/products/express-edition/overview/index.html
Oracle Database 11g Express Edition
Free to develop, deploy, and distribute
Oracle Database 11g Express Edition (Oracle Database XE) is an
entry-level, small-footprint database based on the Oracle Database 11g
Release 2 code base. It's free to develop, deploy, and distribute;
fast to download; and simple to administer.
Oracle Database XE is a great starter database for:
Developers working on PHP, Java, .NET, XML, and Open Source
applications
DBAs who need a free, starter database for training and deployment
Independent Software Vendors (ISVs) and hardware vendors who want a
starter database to distribute free of charge
Educational institutions and students who need a free database for
their curriculum
With Oracle Database XE, you can now develop and deploy applications
with a powerful, proven, industry-leading infrastructure, and then
upgrade when necessary without costly and complex migrations.
Oracle Database XE can be installed on any size host machine with any
number of CPUs (one database per machine), but XE will store up to
11GB of user data, use up to 1GB of memory, and use one CPU on the
host machine.
Support is provided through a free Oracle Discussion Forum monitored
by Oracle employees as well as community experts.
You can use Oracle XE (Express Edition) which is free.
You can download it here.
Assuming that each developer needs less than 11 GB of data in their personal copy of the database, have you looked at using the free express edition of the Oracle database? You can install that on your local machine or even deploy it in production free of charge. You can't use enterprise edition features but basic PL/SQL should work exactly as it does in whatever edition of the database you're using now.
It's not obvious to me, however, that this is really the solution to the problem you're having. If test cases are getting changed without that information getting communicated to developers or test data that one person is relying on is being changed by some other person, creating more database instances with more copies of the same data isn't likely to be terribly helpful. If you have a local copy of the database, you need some way of getting the current version of all the objects (tables, packages, triggers, etc.). You need some way of getting the data that a particular tester is relying on. You need some way of moving your changes from your machine to the shared databases in a way that doesn't stomp on the changes other developers are making. None of these hurdles are insurmountable, but they do require a very solid build and deployment process-- otherwise, you end up with chaos where the version of code in your database is subtly different than the version of code in everyone else's database and the test data in your system has slightly different characteristics than the test data that QA is using leading to lots of bugs that are reproducible on one system but not another. If your current build and deployment process can't even ensure that test cases aren't changing while bugs are being investigated, I would tend to expect that adding more instances is going to make the problem worse, not better.

How to use Oracle 11g client?

I may be asking something silly but I don't see any sql*plus or any GUI kind of interface to connect my Oracle server remotely. I tried SQL Plus but it's a command line interface, don't know what to do with that.
Oracle SQL developer is a GUI client
pl/sql developer and toad are both decent, but nonfree, Oracle gui clients. If you're going to do a lot of work on packages or stored procs/funcs, one of these will be worth every bit of money you spend.
squirrel sql is an opensource client. There's a squirrel-derived plugin for eclipse called SQL Explorer; it's really good for looking at your data to help get your programs right.

What is the perfect toolbox for PL/SQL development?

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

Resources