views:

731

answers:

3

Lucky me, I have to work with Oracle. And packages.

I have a package that a lot of different developers are touching and it's scaring me. Is it possible to put a package inside of Version Control? Is there some kind of software out there that already does this? If not, is there some kind of export procedure? Can I just grab a file off of a file system?

+5  A: 

How are they inputting it? The way we used to work at my last job is editing a text file, and loading it with SQL*Plus. You can just put that source file under version control.

The source must be between "CREATE OR REPLACE PACKAGE MYPACKAGE AS" and "END;" followed by a single slash on a line of its own ("/"); and ditto for "PACKAGE BODY" instead of "PACKAGE".

And yes, there's a way to pull the source out of Oracle. It's in a table, line by line, look up ALL_SOURCE and USER_SOURCE. You can pull it out with a query like

SELECT TEXT FROM ALL_SOURCE
WHERE TYPE='PACKAGE BODY'
  AND NAME='MYPACKAGE' 
  AND OWNER='MYPACKAGEOWNER'
ORDER BY LINE

(untested as I no longer have access to Oracle) and ditto for the 'PACKAGE'.

I think it's best to load it again into Oracle using SQL*Plus; make sure to set "SCAN OFF".

bart
Dave Costa
And when you roll out a new version of your application, always use the latest packages from version control. Your developers would not accept less for their java, c#, etc.
WW
+1  A: 

We have a database level trigger to capture changes to packages and save the source in a seperate table. It's not as good as version control, but at least you know when something changes and can retrieve it if a later change tramples on it.

Leigh Riffel
A: 

You can download sql developer for free: http://www.oracle.com/technology/products/database/sql_developer/files/what_is_sqldev.html. It integrates with subversion and cvs.

There is also a Visual Studio plugin (http://www.oracle.com/technology/tech/windows/odpnet/index.html). I don't know whether you use Visual Studio or not?

tuinstoel