Using Source Code Control in Oracle SQL Developer

Purpose

This tutorial shows how to use the source code control feature in Oracle SQL Developer.

Time to Complete

Approximately 20 mins

Topics

This tutorial covers the following topics:

 Overview
 Prerequisites
 Creating a Database Connection
 Viewing the Files to be Versioned
 Creating a Repository
 Importing the Files to be Versioned
 Working with the Files Under Version Control
 Summary

Viewing Screenshots

 Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: This action loads all screenshots simultaneously, so response time may be slow depending on your Internet connection.)

Note: Alternatively, you can place the cursor over an individual icon in the following steps to load and view only the screenshot associated with that step. You can hide an individual screenshot by clicking it.

Overview

What Is 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.

Introduced in release 1.5, SQL Developer is tightly integrated with the source code control systems CVS and Subversion, thus allowing you to work with files placed under source code control.
This tutorial does not aim to teach you how to use subversion or source code control, but introduces you to working with a source code control system using SQL Developer. Initially, to place files under source code control they are added to a repository. You must check them out to work them. They can be kept or discarded, but until they are checked back in, the repository has no knowledge of them. Until checked in, the point of truth is the file in the repository.
In this tutorial, using an open source Subversion installation, you place a few files under source code control, check them out, modify one file and return it to the repository.

Back to Topic List

Prerequisites

Before you perform this tutorial, you should:

1.

Install the Oracle Database 10g or later or Oracle Database XE.

2.

Install Oracle SQL Developer 1.5.1.
Note: Oracle SQL Developer is available for download for FREE from OTN. To install Oracle SQL Developer, unzip it into any directory on your machine.

3.

Download and unzip the srccode.zip file into your working directory (i.e.wkdir)

Back to Topic List

Creating a Database Connection

To create a database connection, perform the following steps:

1.

Open Oracle SQL Developer from the icon on your desktop.

 

2.

In the Connections tab, right-click Connections and select New Connection. A New / Select Database Connection window will appear.

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

 

3.

Enter HR in the Connection Name field (or any other name that identifies your connection) and hr for the Username and Password fields. Select the Save Password check box. Enter <hostname> in the Hostname field and orcl in the SID field. Click Test.

 

4.

Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. To save the connection, click Connect. Close the window.

 

5.

The connection is saved and you can see it listed under Connections in the Connections tab.

 

6.

Expand HR. A SQL Worksheet opens automatically. The SQL Worksheet allows you to execute SQL against the connection you just created.

 

Back to Topic List

Viewing the Files to be Versioned

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:

1.

Click View > Files.

 

2.

The Files navigator will appear.

 

3.

In the Files navigator, browse and open the file PROC_EMP_CURSOR.sql.

 

Back to Topic List

Creating a Repository

To create a Subversion repository, perform the following steps:

1.

Click Versioning > Subversion > Create Repository.

 

2.

Provide C:\Documents and Settings\<user>\repos0 as the Repository Path and hr as the Connection Name. Then click OK.

 

3.

The repository for the hr connection is created and listed in the Versioning Navigator.

 

Back to Topic List

Importing the Files to be Versioned

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

1.

In the Files navigator, browse to the location where the files to be versioned are saved.

 

2.

Click Versioning > Subversion > Import Files.

 

3.

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

 

4. Select C:\Documents and Settings\<user>\repos0 as the destination repository connection. Click Next.

5.

Click browse and select the directory where you unzipped the files contained in the prerequisite section. Click Next.

 

6. In the Filters page, click Next.

 

7. In the Options page, ensure that the Perform Checkout check box is selected. Click Next.

 

8. Review the options for the Import operation and click Finish.

 

9. In the Versioning Navigator, select Subversion > hr and click the Refresh icon.

 

10.

Expand the hr node. You can now see the files in your Subversion Repository. These are read only files and display the current state of your files.

 

11.

In the File Navigator, browse and select the file PROC_EMP_CURSOR.sql. Notice the new overlay icon on the file.

 

Back to Topic List

Working with the Files under Version Control

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

1.

In the File Navigator, browse and open file PROC_EMP_CURSOR.sql.

 

2.

Delete the EXCEPTION block.

 

3. Add the following comment and click the History tab.

--To add an exception block type excep and the press Ctrl+Shift+t.

4.

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

 

5. Click File > Save. Notice the change in the icon overlay.

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

7. Click OK in the Commit Resources window.

Back to Topic List

 

Summary

In this tutorial, you 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

Back to Topic List

 Place the cursor over this icon to hide all screenshots.

Left Curve
Popular Downloads
Right Curve
Untitled Document