I need somehow compare local version of pl sql package with the one that is stored in database. Are there any "easy" way to do it? Currently I download package from database, save it in some file and perform diff using some diff tool. That is a bit cumbersome, so I would like to have such feature in ide (pl sql developer is preferable).
-
plenty of diff tools out there. Why not use CVS or Subversion for source control, which through a client like Eclipse (or SQL Developer or Toad or other ides) you can easily step through any changes with latest version? – tbone Feb 08 '12 at 14:45
-
@tbone, how can I using subversion only compare local package file to the one that is in database? – michael nesterenko Feb 08 '12 at 15:02
-
You'll have your local workspace with the changes you made, and then you can compare with the latest (or any) version under source control. – tbone Feb 08 '12 at 15:03
-
One way is do a query, using system or other privileged user, in the table "all_source". But the result will be more simple than a diff tool. – Feb 08 '12 at 16:34
-
@tbone, and what about package that is in database? I don't see how your solution could help me with my problem. – michael nesterenko Feb 08 '12 at 21:15
-
@SérgioMichels, I could do that of courcse, but I am looking for a tool that automates this routine actions. – michael nesterenko Feb 08 '12 at 21:18
2 Answers
Typically developers use versioning software to check differences, maintain version history, and help coordinate team development of code. PL/SQL code should be no different. There's many ways to handle code releases, the following is just what I've seen done, not necessarily the "best" way.
In the Oracle environments I've seen, CVS or SVN is used. Most approaches involve checking out latest code from repository, editing (tagging/branching), and checking in. When code is tested (development instance) and release is ready, the DBAs either grab the release scripts from repository and apply, or one individual is tasked with handing over the correct release scripts to DBAs (more common from my experience). Note that the database here is typically a user acceptance instance that mirrors the production instance. If app testing passes, the code is promoted to production.
If you want to sync directly between the database and your IDE, the one option I've seen is Toad Team Coding. Toad is not free, and this option will require additional objects installed on the database (metadata/tracking tables, etc). A good overview is found here, and good setup article is found here.
Team coding is very cool, but I would only install on a development environment. How you promote the code from there through your system is up to you.

- 15,107
- 3
- 33
- 40
It's fairly easy to automate the procedure you described with a sqlplus command file. Select from all_source, spool it to a file. Invoke the diff command as "host diff ..." or "!diff ..." within the command file. The -b and -B options to diff will ignore whitespace and blank lines respectively.

- 11
- 3