Professional Documents
Culture Documents
Creating User Defined Extensions
Creating User Defined Extensions
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Time to Complete
Purpose Time to Complete Overview Prerequisites Creating a Database Connection Sharing Reports Adding a Tab to Display Column Comments Reviewing the XML File Structure Adding a Tab to Describe Sub-partitions Adding a Context Menu Summary
Approximately 40 mins.
Overview
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 number 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.
Before starting this tutorial, you should: Install Oracle SQL Developer 3.0 from OTN. Follow the release notes here. Install the Oracle Database 11g. Unlock the HR user. Login to SQL Developer as the SYS user and execute the following command: alter user hr identified by hr account unlock; Download and unzip the sql_files.zip file that contains all the files you need to perform this tutorial.
4 . Enter the following and click Test: Connection Name: HR_ORCL Username: hr Password: <your_password> Select Save Password Hostname: localhost Port: 1521 SID: <your_SID>
1 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
5 . Check for the status of the connection on the left-bottom side (above the Help button). It should read Succes save the connection, click Connect.
6 . Once the connection is saved, you will see the database in the list. When a connection is created, a SQL Wo is opened automatically. The SQL Worksheet allows you to execute SQL against the connection you just crea
Sharing Reports
You can share user-defined reports by adding them as an extension to Oracle SQL Developer. To do this, perform the following steps: 1 . Select the Reports tab. Note: If this tab is not visible, select View > Reports.
2 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
2 . Expand each of the nodes. There are a selection of shipped reports under the Data Dictionary Reports nod
3 . There are also shipped Data Modeler Reports. Any report you create is added under the User Defined Re node.
3 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
4 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
7 . Click in the field under Type and select REPORT from the list.
5 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
9 . Browse to the directory where you unzipped the files from the Prerequisites section and select the employees_reports.xml file. Then click Save .
6 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
11 . Exit and restart Oracle SQL Developer for the changes to take effect.
12 . The Shared Reports node is added in the Reports tab (View > Reports).
Note: If you do not see the Shared Reports node, then the extension was not saved properly in the previous
13 . Expand the Shared Reports and EmployeeReports nodes and select Employees per Manager.
7 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
14 . Select the HR_ORCL connection, if prompted, to run the report.
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
on the per Manager report. Note that the context menu does not permit you to edit th 15 . Right-click Adding a Tab to Employees Display Column Comments report. You can copy and recreate it as a User Defined report, but shared reports are not editable. Each object in the Navigator has a matching set of definition tabs. These are based on queries against the Data Dictionary. Not all features describing an object are displayed in these tabs. To create a Column Comments tab for a table, perform the following steps: 1 . Select the Connections and expand the connection. Note: If this tab is not visible, select View > Connections.
8 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
3 . The initial tab displayed is the Columns. Select the Constraints and view the details displayed.
4 . Click through the other tabs to view the details available for a table.
9 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
5 . You can also display the column comments for a table in a tab. To do this you need to add an extension. Sele Tools > Preferences.
6 . As before, expand the Database node and select User Defined Extensions. Click Add Row .
10 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
7 . Click in the field under Type and select EDITOR from the list.
11 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
9 . Browse to the directory where you unzipped the files from the Prerequisites section and select the comment_tab.xml file.
12 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
11 . Exit and restart Oracle SQL Developer for the changes to take effect.
12 . Expand the HR_ORCL connection from the Connections tab. Expand the Tables node and select EMPLOY
13 . Click through the tab till you reach the last tab. A new Column Comments tab is added after the other tabs.
13 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Note: If you do not see the Column Comments tab, then the extension was not saved properly.
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
2 . Browse to the directory where you unzipped the files from the Prerequisites section. Select the comment_ta file and click Open.
14 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
4 . The Oracle SQL Developer framework recognizes the XML tags. The tags you are interested in are the title SQL query tags. The title here is Column Comments and is used to name the tab.
5 . The SQL query is querying the Data Dictionary for the column comments for the OWNER and OBJECT_NA this example, the EMPLOYEES Table for the HR schema.
15 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
2 . Browse to the directory where you unzipped the files from the Prerequisites section. Select the cust_part.sq click Open.
16 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
4 . Select the HR_ORCL connection from the drop-down list on the right of the SQL Worksheet.
17 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
18 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
7 . Expand the Database node and select User Defined Extensions. Click Add Row .
8 . Click in the field under Type and select EDITOR from the list.
19 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
10 . Browse to the directory where you unzipped the files from the Prerequisites section and select the subpartition_tab.xml file.
20 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
12 . Exit and restart Oracle SQL Developer for the changes to take effect.
HR_ORCL connection in the Connections tab. Expand the Tables node and select the 13 . Expand Adding a the Context Menu
CUSTOMERS_PART table. In the above examples, you added tabs to the table definition using XML files. You can add context menus using a similar approach. Context menus can be added at any level to the existing context menu structure. In this example, you add a high-level context menu to set a transaction to READ ONLY. To add a new context menu, perform the following steps: 1 . In Oracle SQL Developer, select File > Open.
21 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
2 . Browse to the directory where you unzipped the files from the Prerequisites section. Select the readonly_me file and click Open.
22 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
4 . This XML file is more involved. Notice that in this case there are two sections; one for Set Read Only and the for Set Read/Write . The image below highlights one of the sections between the <item > tags.
23 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
7 . Expand the Database node and select User Defined Extensions. Click Add Row .
24 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
8 . Click in the field under Type and select ACTION from the list.
25 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
10 . Browse to the directory where you unzipped the files from the Prerequisites section and select the readonly_menu.xml file.
26 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
12 . Exit and restart Oracle SQL Developer for the changes to take effect.
13 . Select the HR_ORCL connection and right-click to invoke the context menu. Scroll to the bottom and select S Read Only .
14 . The title Set Read Only is displayed in the dialog header. Notice the Prompt. The text is from the following p the xml file. <prompt type="confirm"> <label>Confirm Setting Connection to Read Only.</label> </prompt>
27 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
15 . Select the SQL tab. Find the equivalent SQL code in the XML file. Click Apply .
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
16 . The final Confirmation dialog is also driven by the XML file. Click OK.
17 . Expand the HR_ORCL connection and expand the Tables node. Select EMPLOYEES. Select the Data tab.
28 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
Viewing Screenshots
Click icon to hide all screenshots
29 of 30
10/10/2011 17:49
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/sqldev...
Print Preview
20 . You are not able to commit the records due to the READ ONLY transaction.
Viewing Screenshots
Click icon to hide all screenshots Note: Alternatively, you can click an individual icon (or image) associated with each step to view (or hide) the screenshot associated with that step.
Summary
In this tutorial, you have learned how to: Create a Database Connection Share Reports Add a Tab to Display Column Comments Review the XML File Structure Add a Tab to Describe Sub-partitions Add a Context Menu
30 of 30
10/10/2011 17:49