Thursday, 29 September 2016

Using Source Code Control in Oracle SQL Developer

Oracle SQL Developer is a free graphical tool that enhances productivity and simplifies database development tasks. Using Oracle SQL Developer, you can browse database objects, run SQL statements, edit and debug PL/SQL statements and run reports, whether provided or created.

Developed in Java, Oracle SQL Developer runs on Windows, Linux and the Mac OS X. This is a great advantage to the increasing numbers of developers using alternative platforms. Oracle SQL Developer is built on an extensible framework and, as such, is extensible itself. You can create basic XML extensions or more involved Java extensions to add utilities or other functionality to the product.

You can use the version control feature of SQL Developer to import files into your source control system, check them out, modify and commit the changes back.

Before starting this tutorial, you should:
·         Install Oracle SQL Developer 2.1 early adopter from OTN.
·         Install the Oracle Database 10g and later.

Note: If you already have a database connection, you need not perform the following steps, you can move straight to Viewing the Files to be Versioned.
1.     Open Oracle SQL Developer.
2.     In the Connections tab, right-click Connections and select New Connection.

Note: If this tab is not visible, select View > Connections.

You can view the files stored in your local file system by using the Files navigator. To view the files to be versioned, perform the following steps:

Click View > Files
The Files navigator will appear.
In the Files navigator, navigate to the directory where you unzipped the files from the Prerequisites and open the filePROC_EMP_CURSOR.sql.

Creating a Repository 

To create a Subversion repository, perform the following steps:
Note: If you already have a Subverison repository, you can skip this step.

Click Versioning >Create Local Repository

Provide C:\repos as the Repository Path and hr_orcl as the Connection Name. Then click OK.

Expand the Subversion node in the Versioning Navigator. The repository for the hr_orcl connection is created.

Right-click on the hr_orcl connection and select New Remote Directory... 

Enter the name SQLFiles and click OK.

To import the files to be versioned into the Subversion repository, perform the following steps:

In the Files Navigator, select the directory where you unzipped the files from the Prerequisites under the Files tab.

Click Versioning > Import Files 

In the Welcome page of the Import to Subversion wizard, click Next

Ensure that hr_orcl[file:///C:\repos] is the destination repository connection. Select the node SQLFiles and click Next.

Click Browse and select the directory where you unzipped the files from the Prerequisites as the source directory. ClickNext.
In the Filters page, click Next

In the Options page, deselect the Perform Checkout check box and click Next

Review the options for the Import operation and click Finish 

In the Versioning Navigator, expand hr_orcl > SQLFiles

You can now see the files in your Subversion Repository

To work on the files that are placed under version control, perform the following steps:

In the File Navigator, expand the directory where you unzipped the files from the Prerequisites. Notice the check out icon indicating that the files in this directory have been checked out. 

Double click the PROC_EMP_CURSOR.sql file

Delete the EXCEPTION block.

Add the following comment and click the Save icon

Click the History tab.

The History tab displays the changes you have done to PROC_EMP_CURSOR.sql. You can right-click on a version and move between the various changes done.


To check-in the file, in the File Navigator, right-click the file PROC_EMP_CURSOR.sql and select Versioning > Commit.

Click OK in the Commit Resources window

Your file was imported successfully. Notice that the version number has increased by 1.

In this tutorial, you have learned how to:
·         Create a Database Connection
·         View the Files to be Versioned
·         Create a Repository
·         Import the Files to be Versioned
·         Work with the Files Under Version Control

No comments:

Post a Comment