Professional Documents
Culture Documents
PLSQL Manual
PLSQL Manual
0
Users Guide
January 2015
Contents
CONTENTS ........................................................................................................................................... 3
1.
INTRODUCTION...................................................................................................................... 9
2.
2.1
2.2
2.3
2.4
2.5
3.
4.
INSTALLATION ..................................................................................................................... 13
SYSTEM REQUIREMENTS.................................................................................................... 13
WORKSTATION INSTALLATION .......................................................................................... 13
SERVER BASED INSTALLATION .......................................................................................... 13
SCRIPTED INSTALLATION .................................................................................................. 14
UNINSTALLING PL/SQL DEVELOPER ................................................................................ 14
LOGGING ON TO AN ORACLE DATABASE.................................................................... 15
8.
14.
PROJECTS ............................................................................................................................ 110
14.1
CREATING A NEW PROJECT .............................................................................................. 110
14.2
SAVING A PROJECT .......................................................................................................... 111
14.3
ADDING FILES TO A PROJECT ........................................................................................... 111
14.4
ADDING DATABASE OBJECTS TO A PROJECT .................................................................... 111
14.5
WORKING WITH PROJECT ITEMS ...................................................................................... 112
14.6
COMPILING A PROJECT .................................................................................................... 113
15.
TO-DO ITEMS ...................................................................................................................... 114
15.1
CREATING A TO-DO ITEM ............................................................................................... 115
15.2
EDITING A TO-DO ITEM................................................................................................... 115
15.3
CLOSING A TO-DO ITEM.................................................................................................. 116
15.4
DELETING A TO-DO ITEM ................................................................................................ 116
16.
THE CONNECTION LIST ................................................................................................... 117
16.1
USING THE CONNECTION LIST ......................................................................................... 117
16.2
DEFINING FOLDERS AND CONNECTIONS .......................................................................... 120
17.
CONNECTIONS, WINDOWS, SESSIONS AND TRANSACTIONS ............................... 123
17.1
THE MAIN CONNECTION .................................................................................................. 123
17.2
WINDOW CONNECTIONS .................................................................................................. 123
17.3
SESSION MODE ................................................................................................................ 124
17.4
EXECUTION IN MULTI SESSION OR DUAL SESSION MODE................................................. 124
18.
BROWSING OBJECTS ........................................................................................................ 125
18.1
USING THE OBJECT BROWSER ......................................................................................... 125
18.2
OBJECT BROWSER FILTERS ............................................................................................. 132
18.3
OBJECT BROWSER FOLDERS............................................................................................ 133
19.
BROWSING FILES............................................................................................................... 135
19.1
SETTING UP THE FILE BROWSER ...................................................................................... 136
19.2
USING THE FILE BROWSER .............................................................................................. 137
20.
PREFERENCES .................................................................................................................... 138
20.1
ORACLE CONNECTION .................................................................................................. 139
20.2
ORACLE OPTIONS ......................................................................................................... 140
20.3
ORACLE COMPILER ...................................................................................................... 142
20.4
ORACLE DEBUGGER ..................................................................................................... 143
20.5
ORACLE OUTPUT .......................................................................................................... 144
20.6
ORACLE TRACE ............................................................................................................ 145
20.7
ORACLE PROFILER ........................................................................................................ 145
20.8
ORACLE LOGON HISTORY ............................................................................................ 147
20.9
ORACLE HINTS ............................................................................................................. 148
20.10
USER INTERFACE OPTIONS ........................................................................................... 150
20.11
USER INTERFACE OBJECT BROWSER ............................................................................ 152
20.12
USER INTERFACE EDITOR ............................................................................................. 153
20.13
USER INTERFACE FONTS............................................................................................... 157
20.14
USER INTERFACE CODE ASSISTANT ............................................................................. 158
20.15
USER INTERFACE KEY CONFIGURATION....................................................................... 159
20.16
USER INTERFACE APPEARANCE .................................................................................... 160
20.17
USER INTERFACE NLS OPTIONS ................................................................................... 162
20.18
WINDOW TYPES PROGRAM WINDOW ........................................................................... 163
20.19
WINDOW TYPES SQL WINDOW .................................................................................... 165
20.20
WINDOW TYPES TEST WINDOW ................................................................................... 168
20.21
WINDOW TYPES PLAN WINDOW .................................................................................. 168
20.22
TOOLS DIFFERENCES .................................................................................................... 168
20.23
TOOLS DATA GENERATOR............................................................................................ 169
20.24
TOOLS TO-DO LIST....................................................................................................... 170
20.25
TOOLS RECALL STATEMENT ......................................................................................... 170
20.26
FILES DIRECTORIES ...................................................................................................... 171
20.27
FILES EXTENSIONS ....................................................................................................... 173
20.28
FILES FORMAT .............................................................................................................. 174
20.29
FILES BACKUP .............................................................................................................. 175
20.30
FILES HTML/XML....................................................................................................... 176
20.31
OTHER PRINTING .......................................................................................................... 177
20.32
OTHER UPDATES & NEWS ............................................................................................ 178
20.33
PREFERENCE SETS ........................................................................................................... 179
21.
TOOLS ................................................................................................................................... 181
21.1
OBJECT BROWSER ........................................................................................................... 181
21.2
FIND DATABASE OBJECTS ............................................................................................... 181
21.3
COMPILE INVALID OBJECTS ............................................................................................ 182
21.4
EXPORT TABLES.............................................................................................................. 183
21.5
IMPORT TABLES .............................................................................................................. 186
21.6
EXPORT USER OBJECTS................................................................................................... 188
21.7
TEXT IMPORTER .............................................................................................................. 189
21.8
ODBC IMPORTER ............................................................................................................ 192
21.9
DATA GENERATOR .......................................................................................................... 194
21.10
COMPARE USER OBJECTS................................................................................................ 198
21.11
COMPARE TABLE DATA .................................................................................................. 200
21.12
EVENT MONITOR............................................................................................................. 202
21.13
SESSIONS ......................................................................................................................... 203
21.14
USER DEFINED TOOLS..................................................................................................... 205
21.15
TEST MANAGER .............................................................................................................. 209
22.
THE EDITOR ........................................................................................................................ 213
22.1
SELECTION FUNCTIONS ................................................................................................... 213
22.2
COLUMN SELECTION ....................................................................................................... 213
22.3
CODE ASSISTANT ............................................................................................................ 214
22.4
RECALLING STATEMENTS ................................................................................................ 215
22.5
SPECIAL COPY ................................................................................................................. 216
22.6
PASTE FROM HOST LANGUAGE ........................................................................................ 217
22.7
CONTEXT SENSITIVE HELP ............................................................................................... 218
22.8
DATABASE OBJECT POPUP MENU ..................................................................................... 218
22.9
EXPLAIN PLAN ................................................................................................................ 218
22.10
MACROS.......................................................................................................................... 218
22.11
BOOKMARKS ................................................................................................................... 219
22.12
COLOR MARKS ................................................................................................................ 220
22.13
CODE CONTENTS ............................................................................................................. 221
22.14
CODE HIERARCHY ........................................................................................................... 222
22.15
CODE FOLDING ............................................................................................................... 223
22.16
SPLIT EDITING ................................................................................................................. 223
22.17
HYPERLINK NAVIGATION ................................................................................................ 224
22.18
NAVIGATION BUTTONS.................................................................................................... 224
22.19
REFACTORING ................................................................................................................. 225
22.20
SEARCH BAR ................................................................................................................... 225
22.21
WEB SEARCH .................................................................................................................. 227
23.
THE LARGE DATA EDITOR ............................................................................................. 229
23.1
EDITING PLAIN TEXT ....................................................................................................... 230
23.2
EDITING RTF .................................................................................................................. 230
23.3
EDITING XML ................................................................................................................. 231
23.4
EDITING HTML .............................................................................................................. 232
23.5
EDITING IMAGES ............................................................................................................. 232
23.6
EDITING HEX DATA ......................................................................................................... 232
23.7
INVOKING AN EXTERNAL VIEWER OR EDITOR .................................................................. 233
24.
THE QUERY BUILDER....................................................................................................... 235
24.1
CREATING A NEW SELECT STATEMENT ............................................................................ 235
24.2
MODIFYING AN EXISTING SELECT STATEMENT ................................................................ 238
24.3
MANIPULATING THE QUERY DEFINITION ......................................................................... 238
24.4
QUERY BUILDER PREFERENCES ...................................................................................... 239
24.5
QUERY BUILDER PLUG-INS ............................................................................................. 240
25.
THE PL/SQL BEAUTIFIER ................................................................................................ 241
25.1
DEFINING THE OPTIONS ................................................................................................... 241
25.2
DEFINING THE RULES ...................................................................................................... 242
25.3
USING THE BEAUTIFIER ................................................................................................... 243
25.4
SUPPRESSING FORMATTING ............................................................................................. 243
26.
TEMPLATES ......................................................................................................................... 244
26.1
THE TEMPLATE WINDOW ................................................................................................ 244
26.2
USING A TEMPLATE ......................................................................................................... 245
26.3
CREATING AND MODIFYING TEMPLATES ......................................................................... 246
27.
WINDOW LIST ..................................................................................................................... 249
28.
29.
30.
AUTHORIZATION ............................................................................................................... 255
30.1
ENABLING AUTHORIZATION ............................................................................................ 255
30.2
DEFINING AUTHORIZATION ............................................................................................. 256
30.3
DISABLING AUTHORIZATION ........................................................................................... 257
31.
ORACLE FILE SYSTEM (OFS) .......................................................................................... 258
31.1
OFS MANAGER ............................................................................................................... 258
31.2
OFS USAGE ..................................................................................................................... 260
32.
HELP SYSTEMS ................................................................................................................... 262
32.1
MS HELP FILES................................................................................................................ 262
32.2
HTML MANUALS............................................................................................................ 262
33.
CUSTOMIZATION ............................................................................................................... 266
33.1
PREFERENCES .................................................................................................................. 266
33.2
WINDOW LAYOUT ........................................................................................................... 266
33.3
ON-LINE DOCUMENTATION ............................................................................................. 266
33.4
COMMAND-LINE PARAMETERS ........................................................................................ 268
33.5
SQL, PL/SQL AND COMMAND KEYWORDS ..................................................................... 271
33.6
PLUG-INS ........................................................................................................................ 271
1. Introduction
PL/SQL Developer is an Integrated Development Environment (IDE) for developing stored program
units in an Oracle Database. Using PL/SQL Developer you can conveniently create the server-part of
your client/server applications.
As a worst-case scenario, up to now you might have been working like this:
You use a text editor to write program units (procedures, triggers, etc.).
If there is a compilation error, you have to find out where it is located in the source file, correct it,
switch back to SQL*Plus to recompile it, only to find the next error.
You use SQL*Plus or the client-part of your application to test the program unit.
In case of a runtime error, again you have a hard time locating the cause of the problem and
correcting it.
You use the Explain Plan utility or tkprof to optimize your SQL statements.
To view or modify other objects and data in your database, you use SQL*Plus or yet another tool.
These tasks - editing, compiling, correcting, testing, debugging, optimizing and querying - can all be
performed without leaving PL/SQL Developer's IDE. Furthermore, PL/SQL Developer provides several
other tools that can be helpful during every day PL/SQL development.
Editing
PL/SQL Developer, like any other serious development environment, assumes that you store your
source files on disk. Other tools just let you edit sources in the database, but this does not allow for any
version control or deployment scheme. The source files can be run through SQL*Plus, so you can
10
deploy them on any platform without using PL/SQL Developer. You can edit many files at once
through a standard multiple document interface.
The editor offers a wide range of assistance to the programmer. There is context sensitive help on SQL
statements and PL/SQL statements. We've all been there: you start typing substr, but have forgotten the
exact meaning of the parameters. Now you can simply hit F1 and you're taken to the appropriate topic
in the SQL Reference Manual. Tables, views and program units can be described for you in a roll-up
window from within the editor in the same way. A Code Assistant is integrated into the editor that
automatically displays information of database objects as you type their name, allowing you to browse
and pick elements from this description. For large package or type bodies, the program editor provides a
tree view with the code contents for easy navigation, highlights code structures and variable references,
allows you to fold/unfold code sections, and provides hyperlink navigation. The Query Builder allows
you to graphically create select statements. PL/SQL Developers extensible templates make it easy to
insert standard SQL and PL/SQL code into your programs. Al editors use the appropriate SQL, PL/SQL
and SQL*Plus syntax highlighting to make your code more readable.
Optimizing
To optimize the SQL statements in your program units, Oracle's Explain Plan utility can be a big help.
Therefore it is integrated into PL/SQL Developer's IDE. By simply selecting the SQL statement in the
source file and pressing F5, the query plan is visually presented to you in a separate Explain Plan
window. You can then modify the statement to optimize its query plan outside the source file, and copy
it back afterwards.
You can also view statistics about executed SQL statements and PL/SQL program units. These statistics
can include elapsed time, CPU time, logical reads, physical reads, physical writes, and so on.
11
Oracle8i introduced a PL/SQL Profiler that allows you to profile your PL/SQL code. For each executed
line of PL/SQL code you can determine the execution time, and how many times it was executed.
Querying
To query the data in the database, you can use a SQL window to execute any SQL statement. All
executed statements are kept in a history buffer, so you can easily re-execute them. Any query results
are conveniently displayed in a separate grid that you can subsequently use to insert, update, or delete
records. The result grid can additionally be used in a Query By Example mode, so that you can easily
find the information you need.
To query database objects you can use the Object Browser. All relevant properties of database objects
such as tables, views, sequences, functions, procedures, packages, types and triggers can be viewed,
including any dependencies between the objects. The Object Browser uses a tree view similar to the
explorer in Windows for easy point-and-click browsing.
Diagrams
To visualize the database objects of your application or project and their relations, you can create
diagrams. A diagram can be used for documentation purposes, but can also serve as a workspace to
work with related objects.
Reporting
PL/SQL Developer comes with a number of standard reports, which are HTML based. You can view
these reports within PL/SQL Developer, print them, or save them as HTML files. You can also create
your own custom reports. Reports can be made easily accessible from the reports menu.
Graphics
The Graph Window can be launched from within a SQL Window or Report Window to obtain a
graphical representation of the queried data.
Projects
To organize your work you can use PL/SQL Developers project concept. A project consists of a
number of files and database objects. These objects are easily accessible through the Project Items
Window, and can be compiled through a single mouse-click.
Tools
PL/SQL Developer provides several tools that can be helpful during development. These tools include a
Find Database Object tool, allowing you to search for text in database object sources, a Compile Invalid
Objects tool, to quickly compile objects that have become invalid during development, Export and
Import tools, a Data Generator tool to create test data, an Export User Objects tool to export the DDL
12
statements of a users objects, a Compare User Objects tool to compare the object definitions of 2 users,
a Session information tool, an Event monitor, a Compare Table Data tool to compare and equalize table
contents, and a DBMS Scheduler tool to view and manage your scheduler objects and jobs.
In addition to these standard tools, you can define your own tools and include them in PL/SQL
Developers tools menu.
13
2. Installation
There are basically two ways to install PL/SQL Developer:
Workstation installation. In this case you install the software locally on each workstation that it
will be used on.
Server installation. In this case you install the software on a server at a location that can be
accessed from each workstation that it will be used on.
2.1
System requirements
PL/SQL Developer will run on Windows 2000 and later, and is compatible with Oracle Server version
7.0 and later. To connect to an Oracle database, PL/SQL Developer requires a 32-bit Oracle Client
version 7.0 or later.
If you are using a 64-bit version of the Oracle Client and/or Server on your workstation, you will need
to install an additional 32-bit Oracle Client. The 32-bit Oracle Client can communicate with a 64-bit
Server, even on the same machine if necessary. The 32-bit client can coexist with a 64-bit Oracle
installation when installed in separate Oracle Home directories.
2.2
Workstation installation
To install PL/SQL Developer locally on a workstation, run the setup program from the installation
medium. After doing this, the following dialog will appear:
You can select a destination directory for the program files, a folder in the start menu, a location for a
shortcut to PL/SQL Developer on the desktop, and installation options. After pressing the Finish button
on the final page, the program files are copied and the shortcuts are created.
2.3
For multi-user licenses you can create a single PL/SQL Developer installation on a file server and
provide access to all licensed users. To do so, you can run the setup program on the file server in the
same way as described in the previous section. You must choose a destination directory that is shared to
the users that will use the software. When PL/SQL Developer is first run on a workstation, this type of
installation is automatically detected, and local installation is then completed without the user noticing it.
PL/SQL Developer can be installed into a directory where the users have only read access.
14
2.4
Scripted installation
In addition to the installation procedure described above, you can also create a script for unattended
installation. Read the included install.txt file for detailed information.
2.5
If for some reason you wish to uninstall PL/SQL Developer, you can remove it using Add/Remove
Program in the Control Panel.
15
If you cancel this logon dialog you will continue without an Oracle connection. This will disable all
PL/SQL Developer functions that require a connection, such as compiling, querying and so on. You can
connect from within the PL/SQL Developer IDE later to enable these functions.
After entering the username, password and database and pressing OK or <Enter>, you will be
connected to the database and the PL/SQL Developer IDE will be displayed. You can now write
PL/SQL Programs, Test PL/SQL Programs, query the database, and so on, as described in the following
chapters.
If you have multiple databases or multiple database accounts, then you can make additional connections
by using the Log on item from the Session menu, or by using the Log on button on the main toolbar.
Each additional connection will be added to the Connection List (see chapter 16), which can
subsequently be used to view and manage your connections. When starting PL/SQL Developer again
later you can quickly log on by selecting a connection from the Connection List.
Logon failure
The logon dialog can fail for the following reasons:
1.
You do not have the Oracle Client software installed. This is a requirement for PL/SQL Developer.
Install an Oracle Client and try again.
2.
You have more than one Oracle Client software installations. In this case PL/SQL Developer may
have chosen an Oracle Client that is not appropriate. Cancel the logon dialog, go to Tools >
Preferences > Oracle / Connection, select the appropriate Oracle Home from the list, restart
PL/SQL Developer and try again.
3.
You are using an Oracle Instant Client but have not set all required environment variables:
PATH Needs to include the Instant Client directory (where oci.dll is located).
TNS_ADMIN Needs to point to the directory where tnsnames.ora is located.
NLS_LANG Defines the language, territory, and character set for the client.
Note: you can also set these parameters on the command-line or in the params.ini file, as
described in chapter 33.4.
16
4. Writing programs
In an Oracle database, you can distinguish five different types of stored program units: functions,
procedures, packages, types and triggers. The Program editor allows you to create and modify these five
types of program units in one uniform way.
4.1
Creating a program
To create a new program, press the New button on the toolbar and select the Program Window item and,
for example, the Function sub item. You are now prompted for various variables that are relevant to this
program type. In this case, where we are creating a function, the name of the function, the parameter list,
and its return type:
As the title of this dialog suggests, this information comes from a template. PL/SQL Developer provides
several standard templates, which you can modify as needed. You can also define new templates.
Information about defining templates is provided in chapter 26.
After you have entered the variables and pressed the OK button, a Program Editor Window appears with
a template function in it. Each program you create in the Program Editor unit must start with the
familiar 'create or replace' SQL syntax. In this case we are creating a function 'even', and the source file
could look like this:
At the left side of the editor you see the Code Contents, which displays the structure of the program unit.
This is useful when navigating large program units such as package bodies and type bodies. This feature
is described in detail in chapter 22.13.
Above the editor you see the Code Hierarchy, which displays the hierarchy from the cursor position. In
this case it shows that you are located at a Statement (the return statement) within a Sequence of
statements within a Function. For complex programs, this can be helpful to see where exactly you are
17
located, and can help you to select certain portions of the PL/SQL code. This is described in detail in
chapter 22.14.
A program file can contain more than one program unit. By right clicking in the Program Editor, a
popup menu appears that allows you to add or delete a program unit. You can switch between the
program units by selecting the appropriate tab at the top of the window. This way you can conveniently
keep related program units together in one source file. A package specification and body are a good
example of this feature.
A program unit should be positioned after any other program unit in the program file it might reference.
If you create a function 'odd' that references the previously created function 'even', the program editor
should look like this:
4.2
Saving a program
You can save a program file by pressing the Save button on the toolbar. A save dialog appears that
shows some standard extensions for program files:
Program type
Function
Procedure
Package specification & body
Package specification
Package body
Type specification & body
Type specification
Type body
Trigger
Java source
Extension
.fnc
.prc
.pck
.spc
.bdy
.typ
.tps
.tpb
.trg
.jsp
You can change these extensions through a preference as described in chapter 20.27. If one single
function, procedure, package, type, trigger or java source is in the program file, the filename is
automatically derived from the name and type of this program unit. After saving the file, the filename is
shown in the window title.
18
The saved program file has a format that is compatible with Oracle SQL*Plus. As an example, the
source file containing the 'odd' and 'even' function looks like this:
create or replace function Even(Value in integer) return boolean is
Result boolean;
begin
-- Check if there is a remainder after dividing by 2
Result := (Value mod 2 = 0);
return(Result);
end Even;
/
create or replace function Odd(Value in integer) return boolean is
Result boolean;
begin
Result := not Even(Value);
return(Result);
end Odd;
/
When this file is executed through SQL*Plus, both functions will be created.
4.3
Modifying a program
You can open a previously saved program file by pressing the Open button on the toolbar and selecting
the Program file item. If the file was recently used, you can also open it by selecting Reopen from the
File menu or by clicking on the arrow next to the Open button on the toolbar. When you start editing, a
blue colored indicator at the bottom of the window lights up. This indicates that the file is modified, but
not yet saved. There is also a yellow colored indicator, which indicates that the file is modified, but not
yet compiled.
4.4
Compiling a program
You can compile a program file by pressing the Execute button on the toolbar. All program units in the
program file are compiled, starting with the first one, regardless of the program unit that is currently
selected. When an error occurs, compilation is terminated and the editor is positioned at the source line
that caused the error:
If there is more than one error and you wish to correct them, you can click on the next error message at
the bottom of the Program Editor to go to the error location. If you have configured PL/SQL Developer
19
to use the HTML manuals as described in chapter 32.2, you can double-click on a compilation error to
display the corresponding paragraph in the Oracle Error Messages manual.
The compilation error list can also contain hints. Hints do not cause the compilation to fail, but they
may indicate an issue that could cause a run-time error (such as a comparison with null, a function
without a return value, an unused parameter, and so on). For more information about hints, see chapter
20.18.
If an error message is displayed in a message box after compilation, this means that the create statement
failed without actually compiling the source. The error message should explain the cause of the error. If
for example you get the 'create or replace' syntax wrong, it will say "ORA-00900: Invalid SQL
statement" in a message box.
Note: If you are using Oracle Server 7.2 or earlier, a trigger compilation error is always reported in a
message box. Only since Oracle Server 7.3, trigger compilation errors are reported in the same way as
procedures, functions, packages and types.
4.5
Comparing a program
To compare a program source to another version in the database or on the file system, you can rightclick on the editor and click on the Compare to submenu-item:
These 4 functions will show a visual line-by-line difference between 2 program sources. The Configure
External Difference Tool button allows you to configure the difference tool should be used. By default
the ExamDiff utility will be used, for which a Pro version is available (See the About item of
ExamDiffs Info menu). See also chapter 20.22.
Current file
If you have opened a file from the file system and have made some changes, this function will show the
differences between the file on disk and the Program Window. After saving the Program Window these
two versions will always be the same. If there is no file associated with the Program Window, this
function will be disabled.
Other file
This function allows you compare the current Program Window to any file. After selecting the file, the
differences will be displayed.
20
4.6
Compiler preferences
To set various compiler preferences, you can press the Compiler preferences button on the status line of
the Program Window. This will take you to the corresponding preference page. See chapter 20.3 for
more information.
21
5. Testing programs
After successfully compiling a program, you'll need to test it. To achieve this, you can use PL/SQL
Developer's Test Scripts. A Test Script allows you to execute one or more program units, define input,
output and input/output variables and view and assign values to variables. If a run-time error occurs
during execution of the Test Script, you can view the sources of the program units that were involved in
the error.
If you are using Oracle 7.3.4 or later you can use PL/SQL Developers integrated debugger. You can
step through your code, set breakpoints, view and set variables, view the call stack, and so on.
5.1
There are two ways to create a Test Script. You can simply right-click on a program unit (a standalone
function or procedure, a packaged function or procedure, or an object type method) in the Object
Browser and select the Test item. This will create a new Test Script with variables for the parameters
and result. For the purpose of this manual, we are going to create a Test Script manually from scratch
though.
To create a new empty Test Script, press the New button on the toolbar and select the Test Window item.
You can now type a PL/SQL block with the familiar declare...begin...end syntax in the body of the Test
Script. As an example we're going to test a package employee, which implements some employee
functions of the employee/department demo tables. Function deptname returns the name of the
department of an employee, and can be tested using the following PL/SQL block:
The PL/SQL block contains a simple call to the function that we want to test, and uses variables
deptname and empno. We'll have to assign a value to empno, and after execution, check the value of
deptname to determine if the function returned the correct value.
22
By prefixing these variables with a colon, they can be declared at the bottom of the Test Script:
The Scan source for variables button () at the upper-left of the variables list can be used to quickly
copy the variables from the source. After this, the integer data type and value 7369 (Mr. Smith from the
research department) is assigned to empno. Now we're ready to execute the script.
You can enable a preference (see chapter 20.20) so that the Test Window will automatically search for
bind variables in the source before executing the script.
You can also declare variables locally in a declare part of the PL/SQL block, but you will not be able to
modify or view the values of these variables. An advantage of these local variables is the fact that you
can use record types, PL/SQL tables, types and so on.
5.2
To execute the Test Script, press the Execute button on the toolbar. After execution, the values of the
variables are updated. Any variable whose value has changed is displayed with a yellow background:
The result of the function is 'RESEARCH', so it obviously functions correctly. At the bottom of the
window, the execution time is displayed. This information can be used to optimize your code for
performance. For optimization purposes you can also view the statistics of the execution of the PL/SQL
block by selecting the Statistics tab. You can also create a profile report for each executed line of
PL/SQL code by pressing the Create Profiler report button before executing the script. After execution
you can switch to the Profiler page to view the report. Statistics and Profiler reports are explained in
chapter 6.2 and 6.3 respectively.
You can abort a running Test Script by pressing the Break button, which is particularly useful when a
program is stuck in an endless loop, or execution is taking longer than expected. Note that pressing the
Break button will not always be successful. If for example the program is waiting for a lock, it will not
respond to a break signal.
23
After executing a script, a transaction may have been started by the program units that were executed.
The Commit and Rollback button on the toolbar will be enabled if this is the case. For more information
about transactions, see chapter 17.
5.3
Variable types
The type list in the variables section of the Test Window contains all types that can be used. The
characteristics of these types are explained in this chapter.
Type
Description
Integer
Float
String
Date
Long
The Long data type does not display the value in the grid, but just displays <Long>.
Press the cell button to invoke the text editor.
Long Raw
Pressing the cell button of a Long Raw value will invoke an import/export file
dialog, allowing you to load or save the contents of this variable.
Cursor
This data type can be used where you can use a cursor variable in PL/SQL. After
executing the Test Script, you can press the cell button of the value to display the
result set in a SQL Window.
CLOB, BLOB
& BFile
These LOB Locator variables must be initialized on the server before you can view
the LOB data. The CLOB will invoke a text editor, the BLOB and BFile will
invoke an import/export file dialog.
PL/SQL String
Use this data type for PL/SQL varchar2 values of up to 32000 characters.
Char
Substitution
Substitution variables can be used without the restriction of bind variables. The
variable name in the PL/SQL block is substituted by its value in the text before it is
sent to the server.
Temporary
CLOB &
BLOB
These LOB Locators can already hold data before they are passed to the server
through the Test Script.
Boolean variables
When you select the variable type list-box, you will notice that the Boolean data type is missing. This is
because SQL*Net does not support this data type. To use a Boolean variable, you can declare it as an
integer and use the sys.diutil.bool_to_int and sys.diutil.int_to_bool functions provided by Oracle. These
functions convert between null/true/false and null/0/1. If you use the Test function in the Object
Browser, this conversion is automatically generated for you.
5.4
To save the Test Script, press the Save button on the toolbar. The save dialog uses .tst as the default
extension for Test Scripts, though you can change the default extension with a preference described in
chapter 20.27. The PL/SQL block, all variables (name, type and value), and the debugger watches (see
24
chapter 5.10) are saved. By saving a Test Script you can easily re-test a program unit if you modify it
later.
You can open a previously saved Test Script by pressing the Open button on the toolbar and selecting
Test Script, which will create a new Test Window. You can alternatively right-click on a previously
created Test Window and select the Load item, which will open a Test Script in the existing Test
Window.
Note: You cannot open a SQL*Plus script again as a Test Script. If you want to reuse it in a Test
Window, make sure you save it as a Test Script as well!
5.5
25
Whenever your program unit causes a run-time error, PL/SQL Developer will ask you if you wish to
view the sources of the error stack. This way you can quickly find the cause of the error. If there were
an error in our deptname function, the error stack window would look like this:
At the top you see a tab for each program unit involved in the run-time error. The program units have
been called in right to left order. You can flip through the tabs to easily find the program flow that lead
to the error. In this case it shows that the Test Script has called function employee.deptname. This
obviously can get more complicated and even go across triggers.
Note: If you are using Oracle Server 7.2 or earlier, trigger source will not be shown in the error stack
window.
The error stack highlights each line that was involved in the error in red. For the last program unit in the
stack this is the line that caused the error. For all other program units this is the line where the call to the
next program unit was made.
5.6
When you are editing, compiling and testing packages, the package states will be discarded by Oracle
after each compilation. All global variables in a package will be reset, and the initialization block will
be executed again. This can lead to unexpected results. Whenever PL/SQL Developer detects this
situation, a warning is issued in the status line of the Test Window: "Warning: ORA-04068: Existing
state of packages has been discarded".
Similarly, if you edit and compile a Java source any existing Java session state will be cleared. PLSQL
Developer will also handle this situation, and will display Warning: ORA-29549: class <class name>
has changed, Java session state cleared in the status line.
5.7
In a Test Script you are not limited to PL/SQL blocks. You can also execute single SQL statements,
including select statements. Executing a select statement will display an additional Results tab page,
which displays all selected rows.
5.8
Viewing dbms_output
For debugging purposes it can sometimes be necessary to "print" some information to the screen from
within a program unit. For this purpose Oracle created the dbms_output package. By calling
dbms_output.put_line, information is placed in the output buffer. After execution of a Test Script, you
26
can select the Output tab at the top of the Test Window to view the contents of the output buffer. On
this page you can additionally set the size (0 for unlimited) of the output buffer or enable/disable
buffering. The default settings on the output page are controlled by the output preferences as described
in chapter 20.5.
5.9
If you want to test program units that make use of the PL/SQL Web Toolkit, the HTP Output tab page
will be displayed if any HTP output was generated:
5.10
Debugging
For those programming errors that are really hard to track, the Test Window provides an integrated
debugger. At the top of the window you find a toolbar with functions related to the debugger. To start a
debug session, just press the Start button at the left of the debug toolbar instead of the Execute button in
the main toolbar. The other buttons are now enabled and you are ready to debug.
Controlling execution
After starting the debugger, execution will pause before the first statement in the Test Script. After this,
you can control execution with the buttons in the debug toolbar:
Run the script until completion.
Step into a procedure, function or method call on the next line. If the next line contains an update,
insert or delete statement that will cause a trigger to be fired, you will step into that trigger.
Step over the next line. It will be executed, but you will not step into the source.
Step out of the current program unit.
Run to the cursor line.
Run until an exception occurs. Execution will be paused on the line that causes the exception.
After the next step the exception will actually be raised.
Whenever you step into a program unit, its source will automatically be loaded into the Test Window.
The bottom of the editor panel will now show tabs for each program unit, so that you can easily switch
between them to view the source, set/remove breakpoints, and so on. By right-clicking on the editor
panel you can remove a program unit from the Test Window if you are no longer interested in it:
27
From the same popup menu you can also select to add the variable to the watch list, which means that
after each debug step the variable value will automatically be displayed and updated in the watch list at
the bottom-left of the Test Window.
If a variable is a collection (a PL/SQL table, varray or nested table) of a scalar data type you can view
the entire collection by right clicking on it and selecting View collection variable from the popup menu.
Note that variable values can only be viewed and set if the program units are compiled with debug
information. A preference exists that will cause each compilation to include debug information, and you
can manually add debug information by right-clicking on a program unit in the Object Browser and
selecting the Add debug information item from the popup menu.
Using Breakpoints
Breakpoints can be used to halt program execution on a certain line in your PL/SQL code. When
execution halts, you can view and set variables, step through the code, and so on. You can define a
condition for a breakpoint, in which case execution will only be halted when this condition is met. For
each breakpoint you can define a message that will be placed in the output page when the breakpoint is
reached.
28
Setting breakpoints
There are two ways to set breakpoints: in a Program Window or in a Test Window. In both cases you
simply need to click on the appropriate line in the left margin of the editor. A breakpoint mark will
appear, indicating that a breakpoint is present on that line. When you execute a Test Window in debug
mode, execution will stop if one of the breakpoints is encountered.
If you set a breakpoint in a Program Window, it can be that this particular program unit has not yet been
compiled into the database. Therefore, such a breakpoint cannot be applied to the database yet either. In
this case the breakpoint mark will have a different appearance. When you subsequently compile the
program unit, the breakpoint will be applied and the corresponding mark will change to reflect this. As
long as the program unit is not compiled, any previously set breakpoints in this program unit will be
effective.
You cannot set breakpoints in the PL/SQL block of the Test Script.
To delete a breakpoint, simply click on the breakpoint mark again.
Breakpoint conditions
Sometimes you define a breakpoint on a line that is executed very often, even though you are only
interested in the program status under certain circumstances. In that case you can define a condition for
the breakpoint. Execution will only halt when the condition is met.
To define a condition for a breakpoint, right-click on the mark and select the Modify Breakpoints item
from the popup menu. The following dialog will appear:
In this dialog you see all program units that have breakpoints, with the breakpoints listed below them.
Each breakpoint has a checkbox that can be used to enable or disable it. If you double-click on a
breakpoint you will be taken to its source location in a Program Window. The bottom section displays
the following fields:
Use Condition The checkbox enables or disables the condition. The condition itself should be a
boolean expression. When the breakpoint line is reached, execution will only be halted if the
condition evaluates to True. You can use any SQL expression in the condition, and you can use
any variable that is known at the location of the breakpoint. These are the same variables that you
can view or set during interactive debugging. Variables should be preceded with a colon. For
29
Use Message The checkbox enables or disables the message. When the breakpoint line is
reached, and if the conditions are met, the message will be placed on the output page.
Dont Break This checkbox is only useful if you also define a message. When it is checked,
execution is never halted on this breakpoint line. This way you can define breakpoints that only
generate messages on the output page.
Use Pass Count This checkbox enables or disables the pass count, which defines how many
times the breakpoint line must be passed before execution is halted. If, for example, you define a
pass count of 10, execution will halt every 10th time the breakpoint line is reached.
Note that all fields will be displayed as strings with a limit of 1000 characters. Number and date values
will be converted to string using the NLS format settings of the debug session. Fields of a BLOB or
LONG RAW data type will not be displayed.
30
Debugger preferences
In the Preferences item in the Tools menu you can find a section of debugger related preferences. These
preferences are described in detail in chapter 20.4.
5.11
Tracing execution
You can use the Test Windows Trace facility to trace the execution of your PL/SQL code. You can
configure which events you want to trace: Calls, Exceptions, SQL, or even every executed line of
PL/SQL code. Press the Select Trace Levels button next to the Create Trace report button to bring up
the following configuration screen:
You can control if you want to trace specific events in each program unit (All), only in those program
units that are compiled with debug information (Enabled), or never (None).
To create a Trace report, simply press the Create Trace report on the toolbar of the Test Window and
execute your Test Script. After execution you can switch to the Trace tab page to view the report, and to
view reports of previous runs:
In this (simple) report you can see that a select statement on line 19 of function employee.deptname
raised exception 1403 (No data found), which was handled on line 31 in the same program unit.
31
For each traced event, you can include information in the report like the event description, time,
program unit, line number, exception, and so on. To configure this, press the Preferences button at the
upper left of the Trace toolbar. This will bring up the Trace preferences page as described in chapter
20.6.
To view old trace reports, select a previous trace run from the Run selection list. Press the Delete Run
button to delete the currently selected run.
For more information on the Oracle Trace facility, see the DBMS_TRACE chapter in the Oracle
Supplied Packages Reference manual.
5.12
Regression testing
To use Test Scripts for regression testing, you can use the Test Manager tool (see chapter 21.15) to
define and run Test Sets based on Test Scripts.
32
6. Optimizing
To optimize the SQL statements in your program units, Oracle's Explain Plan utility can be a big help
by showing the execution path of a statement. Therefore it is integrated into PL/SQL Developer's IDE.
To view the actual resource use of a SQL statement or PL/SQL program unit, PL/SQL Developer can
display statistics about its execution. You can configure which statistics you wish to display, and can
include elapsed time, CPU time, logical reads, physical reads, physical writes, and so on.
To determine the execution time of each individual line of PL/SQL code, you can use the PL/SQL
Profiler. This feature is not available on Oracle 8.0 or earlier.
Finally, you can use Oracle's tkprof utility to get resource use information about all executed SQL
statements in a program unit by enabling SQL Trace.
6.1
To use Oracle's Explain Plan utility, press the New button on the toolbar and select Explain Plan
Window. An empty Explain Plan Window appears. In the top half of the window, you can type the SQL
statement you wish to analyze. After pressing the Execute button on the toolbar the execution plan is
displayed in the bottom half of the window:
You can now change the SQL statement and press the Execute button again to see the impact of the
changes. For more information about execution plans, you can read Oracles Server Tuning manual.
To see the effect of different optimizer goals on the query plan, select the corresponding entry from the
Optimizer goal list. The plan will immediately be updated to reflect these changes.
Use the First, Previous, Next, and Last operation buttons to navigate through the query plan in order of
operation. After the plan has been determined, the first operation will be highlighted.
The Explain Plan utility uses a so-called plan table to store the execution plan. If such a table is not
available to the current user, PL/SQL Developer will ask you if it should create this table in the schema
of the current user. To define which columns from the plan table you want to see, and in which order,
press the Preferences button. This will bring up the corresponding preference page (see chapter 20.21).
If you right-click on the Object name column, this will bring up the popup menu for the selected object.
On Oracle11g Server and later you can additionally view the query plan in HTML, Text or XML format.
33
Now the Explain Plan utility knows which identifier is a column, and which identifier is a PL/SQL
variable.
6.2
Automatic statistics
When you execute a statement in a SQL Window or in a Test Window, PL/SQL Developer will
automatically generate a statistic report of this execution. One condition is that you need to have select
privileges on the dynamic performance tables v$session, v$statname and v$sesstat (provided through
the standard plustrace role).
You can view the statistic report by changing to the Statistics tab at the top of the SQL Window or Test
Window. The statistics for the execution of the employee.deptname function might look as follows:
34
For each statistic you see the value of the last execute, and the total for the current session. You can
configure if and which statistics are displayed by setting a preference, as described in chapter 20.2. The
default set of statistics is relevant to the tuning of your SQL and PL/SQL, and is described here:
Statistic
CPU used by this session
Physical reads
Physical writes
session logical reads
sorts (disk)
sorts (memory)
sorts (rows)
table fetch by rowid
table scan blocks gotten
table scan rows gotten
table scans (long tables)
table scans (short tables)
Meaning
The CPU usage in hundredths of a second
The number of blocks read from disk
The number of blocks written to disk
The number of blocks read from the block buffer or from disk
The number of sorts performed in a temporary segment
The number of sorts performed in memory
The number of rows that were sorted
The number of rows fetched by rowid, usually as a result of index accesses
The number of blocks read for full table scans
The number of rows read for full table scans
The number of full table scans on long tables
The number of full table scans on short tables
Which other statistics you can include depends on the version of the Oracle Server and are not described
in this manual. If you wish to get information about them, there are many Oracle tuning books available
that address this topic. The Oracle Server Reference also briefly describes these statistics.
The statistics can be exported to a CSV file (Comma Separated Values) that can be opened in a spread
sheet application later. Just right-click on the statistics, select the Export item and choose the CSV file
item. You can alternatively select a TSV, XML or HTML format, or copy it to the clipboard.
6.3
The PL/SQL Profiler is a very powerful tool to help you optimize your PL/SQL code. For each
executed line of code, the total time, maximum time, minimum time, average time, and the number of
occurrences will be determined.
The Profiler is easily accessible in the Test Window. Before executing a Test Script, simply press the
Create Profiler report button on the toolbar of the Test Window. If you subsequently execute the script,
you can switch to the Profiler page to view the report.
35
The following example report shows that in the employee.deptname function, the select statement took
149 milliseconds, and the 3 dbms_output calls took 57 milliseconds:
By default the Profiler page will display the report of the last run. You can also select previous runs
from the Run list. The Unit list allows you to zoom in on a specific program unit of a run.
The Total time column shows a graphical representation of the relative time of the line, compared to the
line with the highest time. This allows you to quickly identify the lines that are most expensive. The
report can be sorted by pressing on the sort-buttons in the heading of the columns.
If a source line is displayed in red, this means that the program unit has been changed since the profile
report was created. Therefore the displayed line of code can now be different than when the profile was
created.
You can change various layout aspects of the Profiler report by pressing the Preferences button. This
will bring up the corresponding preference page, as described in chapter 20.7.
For more information about the PL/SQL Profiler, see the dbms_profiler chapter in the Oracle8i
Supplied Packages Reference manual.
Note: not all platforms provide equally accurate timing information.
6.4
SQL Trace
You can enable SQL Trace by pressing the SQL Trace button on the toolbar. After this, all server
processing caused by a SQL Window or Test Window will be logged in a trace file on the database
server. One condition is that the timed statistics parameter of the database instance you are using must
be set to true.
You can disable SQL Trace by pressing the SQL Trace button again.
You can view the information in the trace file by using Oracle's tkprof utility on the database server. It
will generate a report about elapsed time, CPU time, I/O, and so on for each SQL statement. Therefore,
it can give you some insight into which statements are the most costly in a program unit. To learn more
about Oracle's tkprof utility, you might read the "Oracle 7 Server Tuning" manual.
The tkprof report for the execution of the employee.deptname function might look as follows:
36
cpu
elapsed
disk
query
current
-------- ---------- ---------- ---------- ---------0.00
0.00
0
0
0
0.01
0.01
0
0
0
0.00
0.00
0
0
0
-------- ---------- ---------- ---------- ---------0.01
0.01
0
0
0
rows
---------0
1
0
---------1
call
count
------- -----Parse
1
Execute
1
Fetch
1
------- -----total
3
cpu
elapsed
disk
query
current
-------- ---------- ---------- ---------- ---------0.00
0.00
0
0
0
0.00
0.00
0
0
0
0.06
0.06
4
4
0
-------- ---------- ---------- ---------- ---------0.06
0.06
4
4
0
rows
---------0
5
1
---------6
37
7. Ad hoc SQL
Often during program development you need to execute some SQL statement. Either to test the SQL
statement, to view data in a table, or to update data. You can do this from within PL/SQL Developer by
using the SQL Window.
7.1
To create a new SQL Window, press the New button on the toolbar and select SQL Window. An empty
SQL Window appears, in which you can type a SQL statement. If it is a select-statement, the window
splits into two parts and shows the results in a grid in the bottom half. If we wanted to view all the
employees in the employee table, the SQL Window would look like this:
The SQL statement is executed and 10 rows have been retrieved. The result set is larger than 10 rows,
which is indicated by the fact that both the Next Page and Last Page buttons on the result set toolbar are
enabled, and the fact that (more) is displayed on the status line. Only 10 are initially retrieved because
this is the number of records that can be displayed on the grid. Pressing the Next Page will retrieve the
next 10 rows, and so on. Pressing the Last Page button will retrieve all rows.
38
If you have multiple SQL statements in the SQL Editor and press the Execute button, all statements will
be executed, and the results will be displayed in separate tab pages:
SQL statements must be terminated with a semi-colon or a slash, and PL/SQL blocks must be
terminated with a slash, just like in SQL*Plus. If you select a result tab, the corresponding text in the
SQL Editor will be highlighted.
If you select a part of the text in the SQL Editor, only the selected text will be executed. This way you
can have more than one statement in the editor, and still execute them one by one.
If you execute a SQL statement that takes a long time to finish you can press the Break button to abort it.
Note that pressing the Break button will not always be successful. If for example the statement is
waiting for a lock, it will not respond to a break signal. If you have pressed the Break button when the
SQL Window is retrieving rows, it will simply stop and display the rows that have already been
retrieved. You can now continue retrieving records with the Next Page and Last Page buttons. To
refresh (re-execute) the query of the currently selected result tab page, you can press the Refresh result
set button.
Note that the SQL Window preferences allow you to determine how many rows are initially retrieved
for a select statement. This is described in chapter 20.19.
At the right side of the window you see two buttons that allow you to navigate through all SQL
statements that you have entered in the SQL Window. This way you can quickly re-execute statements
entered previously.
For optimization purposes you can view the statistics of the execution of the SQL statement by selecting
the Statistics tab. Statistics are explained in chapter 6.2.
When you print a SQL Window, the SQL statement and the result grid will be printed. By selecting
rows in the result grid, you can limit the amount of rows that will be printed.
By default the tab titles will be derived from the statements. To override this you can use a comment
with a tab=<title> expression before the statement. For example:
-- tab=Department 10
select * from emp
where deptno = 10;
39
In this case the tab title is Department 10 instead of the default Select emp.
7.2
The result grid of the SQL Window can be manipulated in various ways. Some cell types have special
behavior, rows, columns, and cell ranges can be selected and printed, columns can be moved, rows can
be sorted, you can switch to a single record view, and so on.
Aligning cells
To quickly align cells based on the column values, you can use the Align button:
If you press this button, the width of each cell will be determined by the column header and the contents.
If you press the pull down button next to the Align button, you can select different alignment options
from the pull down menu. You can limit the width alignment to the header or contents, and you can
additionally align the row heights.
You can also create custom template alignments for specific queries that you frequently use. After
setting the cell widths you can select the Save as template item to save it. If you execute the same query
later, this alignment can either be applied explicitly by selecting the Align from template option, or
implicitly if you enable the Auto-align from template option. Note that in addition to the column widths,
the template will also save the column order.
The Hide Editor option will hide the SQL Editor to maximize the available space for the result set. The
Adjust Window width option resizes the SQL Window width to match the result set width.
When you click on the cell button of such a column, the Large Data Editor is invoked, which allows you
to view or edit the data in various formats. See chapter 23 for more details.
You can also click on the cell button of character columns to invoke the Large Data Editor. The cell
button is only present if the column size is larger than 20 characters.
40
A column selection can now be moved by releasing the mouse button, clicking on one of the selected
column headings again, and dragging the selection to the new location.
41
To select a specific range of cells, move the mouse pointer over the left edge of a cell until its shape
changes, press the mouse button, and drag the mouse to highlight the selection:
To select all rows and columns, press the upper left cell, or right-click on the grid and select the Select
All item from the popup menu.
The highlighted selection can be copied or printed as usual.
Scroll locking
Sometimes you want to prevent that certain key data scrolls off screen. For the example above you may
want to prevent that the empno column scrolls off screen when you scroll the grid contents to the left.
To do so, right-click on the empno column and select Lock columns item from the Scroll lock popup
menu item. To lock more than one column you can lock the rightmost column.
You can lock rows in a similar way: right-click on a row and select Lock rows item from the Scroll lock
popup menu item.
Sorting rows
To sort the rows in a result grid, press the heading button of the column on which you want the rows to
be sorted:
The rows will be sorted in ascending order, as indicated by the heading button. Pressing the heading
button again will sort the rows in descending order. Pressing it a 3rd time will undo the sorting. Pressing
the heading button in another column will sort the rows on this column, but will also use the previous
sort column as the secondary sort column (indicated by the dot in the heading button). In the example
above, the job column is the primary sort column, and the hiredate column is the secondary sort column.
By default the sort order will not be case sensitive. Right-click on the grid and select the Sort case
sensitive item to change the sorting behavior.
Note that sorting is performed locally, and only for the rows that are already retrieved. If you retrieve
additional rows after sorting the results, these new rows will be added at the end of the result grid,
without any sorting. For large result sets, local sorting can take a long time. In this case it might be
better to use an order by clause in the select statement and let the Oracle Server do the sorting.
42
Now each row displays a single column name and value, as well as the column comments if available.
The Next Record and Previous Record on the grid toolbar can be used to navigate through the result set.
To switch back to the Multi Record View, press the Single Record View button again.
Exporting data
There are several ways to export the data in the result set grid. After executing a select statement, you
can select a range of cells as described above, right-click on it, and select the Export Results item from
the popup menu. This will display a submenu where you can choose to export the data in CSV format
(Comma Separated Values), TSV format (Tab Separated Values), HTML format, XML format, or SQL
format. After selecting the format, you can specify the export file. The SQL format will generate a SQL
file with insert statements for the queried table or view. The popup-menu additionally includes a To
clipboard as submenu item, which allows you to export directly to the clipboard in the given format.
You can alternatively copy the selection to the clipboard by pressing Ctrl-C, or by right-clicking on the
selection and selecting the Copy or Copy with Header item from the popup menu. You can subsequently
paste this data in another application like a spreadsheet, word processor, and so on.
To quickly manipulate the result set information in Microsoft Excel, select the Copy to Excel item. This
will export the selected data to a temporary file and open it in Excel. If you are using Excel 2003 or
earlier, use the Copy as xls submenu item. If you are using Excel 2007 or later, use the Copy as xlsx
submenu item. The older xls format has a limit of 65535 records per page, so if the selected data
exceeds this limitation it will be split over multiple Excel pages. If you have multiple result sets you can
also use the Copy all as xls or Copy all as xlsx item instead, which will create separate Excel pages for
each result set. The directory where the Excel files will be created can be controlled through a
preference (see chapter 20.26).
43
To copy just the header names to the clipboard, right-click on a selection of columns and select Copy
Header from the popup-menu.
7.3
After executing a select statement, you can press the Query By Example button above the result grid if
you want to search for specific records. Pressing this button will clear the grid, and leave one empty
record where you can enter your query values. If, for example, you want to find all employees that start
with the letter A in department 20, enter A% in the ename column and 20 in the deptno column:
Pressing the Query By Example button again, or pressing the Execute button, will execute the modified
query and display the restricted results. Press the Query By Example button again to continue with the
previous query values. Press the Clear record button to clear the query values.
Query values are not restricted to single values with wildcard characters. You can use the following
expressions (alternative expressions between square brackets):
value [= value]
> value
< value
Note that if you use a literal value, you can omit quotes for character values (e.g. SMITH will
automatically be converted to SMITH in the SQL text). For all other expressions you must provide a
literal value that the Oracle Server understands (e.g. != SMITH). This is also the case for number and
date values. If you use it in an expression, use a format that the Oracle Server understands.
44
Several preferences exist that allow you to control the default behavior of the Query By Example
functionality (e.g. case sensitivity). Chapter 20.19 describes these preferences.
7.4
Linked Queries
When viewing a result set, you often want to query a related table. For example, when viewing the dept
table, you may want to query all employees of a department, Or vice versa: when viewing the emp table,
you may want to query an employees department.
Most of the time you will have foreign key constraints between these parent and child tables, in which
case the SQL Window can automatically generate and execute these queries for you. If you are located
on a specific record in the result set, press the Linked Query button on the grid toolbar. This will display
a popup menu with all parent and child tables of the table of the current select statement. If, for example,
you were querying the emp table, the following popup menu might appear:
The top section displays the parent tables (and the foreign key names), and the section below that
displays the child tables. The dept item will generate a query for this employees department (30). The
first (parent) emp item will generate a query for this employees manager (7839). The second (child)
emp item, will generate a query for all employees that are managed by this employee:
The new detail SQL Window is dynamically linked to the master SQL Window through implicit bind
variables with the name :m_<master_field> (in this case :m_empno). If you move to a different master
record, the detail SQL Window will automatically refresh for the new master record. The :m_empno
bind variable is updated with the corresponding master field value.
The Custom item allows you to write a custom SQL statement that refers to the master fields with the
same :m_<field> names as described above.
A linked query will be executed in a new SQL Window, unless you disable the SQL Window
preference Linked Query in New Window (see chapter 20.19). If you hold down the Ctrl key while
pressing the Linked Query button, the opposite of this preference will occur. Dynamic master/detail
SQL Windows can only be created when the linked query is opened in a new window.
7.5
45
Substitution variables
You can use substitution variables in your SQL text to allow user input when the query is executed. The
simplest form of a substitution variable is similar to the way you may be used to from SQL*Plus:
By specifying &deptno in the SQL text, you will be prompted for a value for this variable. The variable
reference in the SQL text will be substituted by this value before execution. You can specify more than
one substitution variable, and you can specify a single substitution variable more than once.
Furthermore you can define the data type, default value, selection lists, list queries, checkboxes, and
other advanced options. These features are also used in the Report Window, and are described in detail
in chapter 12.
To suppress variable substitution in the SQL Window, press the &-button at the lower left on the status
bar. The &-sign will go red to indicate that variable substitution is disabled. Press the button again to reenable it.
46
7.6
To update, insert or delete records in the database, you can execute the appropriate DML statements in a
SQL Window. It is probably much more convenient to make a result grid updateable by including the
rowid in the select list or use a select ... for update statement:
You should be aware that a select ... for update statement will lock all selected records, so including the
rowid might generally be the best way to make a result grid updateable. If the select statement is a join,
columns of the first table can be updated. All other columns will be read-only. Columns that are given
an alias cannot be updated either.
If the result grid is updateable, you can press the Edit data button at the right side of the result grid and
edit the records. You can insert or delete records on the grid by pressing the Insert record or Delete
record button. If you have selected multiple records, all selected records will be deleted.
When editing character or number fields, the text color will go red if you enter data beyond the size,
precision, or scale of the underlying column.
After editing a column value that appears in a virtual column expression, the corresponding virtual
column value will be updated as well.
Modifying the result grid does not actually change anything in the database. To post the updated,
inserted or deleted records to the database press the Post changes button. Any column value changes
that are performed by server-side logic (by before insert or update triggers or default values for an insert
statement) will immediately be reflected in the result grid as well.
After posting (if you have the AutoCommit SQL Window option disabled) the Commit and Rollback
button on the toolbar will be enabled if a transaction has been started. For more information about
transactions, see chapter 17.
7.7
47
The SYS.XMLTYPE type is not supported by Oracle Net 9.0 and earlier, so you will not be able to
directly access the XML data that is stored inside such a column. If, for example, xml_text is a
SYS.XMLTYPE column, then the following query will not provide the expected result:
select id, xml_text from xml_table
Only the id column will show up in the result set. To view the XML data, use the getclobval() member
function:
select id, t.xml_text.getclobval() from xml_table t
This way the CLOB can be viewed in the Text Editor, and XML syntax highlighting will automatically
be applied. To edit the XML data, make the result set updateable as usual by including the rowid:
select id, t.xml_text.getclobval(), rowid from xml_table t
Now you can edit the CLOB and post the modified data to the database. Note that the View Data and
Edit Data functions for tables and views will automatically apply these rules, so the easiest way to view
or edit XMLTYPE columns is to right-click on the table or view, and selecting the corresponding items
from the popup menu.
7.8
Comparing records
To compare records within a result set you can press the Compare records button on the result set
toolbar. By default this will highlight identical field values in the result set when compared to the
current record:
If you move to a different row, the highlighted fields will be updated accordingly. Press the Compare
records button again to clear the highlights.
48
If you click on the arrow button next to the Compare records button you can control the following
aspects of the compare function:
Highlight identical Highlights all fields with an identical value as the corresponding field of the
current record.
Highlight different Highlights all fields with a different value as the corresponding field of the
current record.
Case sensitive When selected, field values are compare case sensitive.
7.9
For queries with large result sets (ten thousands of records or more) it may be inconvenient to first
query the data into the result grid, to subsequently export it to a file. This may take a long time and a lot
of memory resources. In this case it is much more efficient to directly write the result set into an export
file. To do so, you can press the Export Query Results... button on the result set toolbar, instead of the
Execute button on the main toolbar. This will display a popup menu where you can choose to export the
data in CSV format (Comma Separated Values), TSV format (Tab Separated Values), HTML format,
XML format, or Excel format. After selecting the format, you can specify the export file, after which
the query will be executed. The result set will not be displayed in this situation, but will only be written
to the export file.
The popup-menu additionally includes a To clipboard as submenu item, which allows you to export
directly to the clipboard in the given format.
7.10
Comment directives
You can use special directives in a comment before each SQL statement to control aspects of the query.
For example:
-- Tab=All managers
select * from emp
where job = 'MANAGER';
-- Tab=Department 10
select * from emp
where deptno = 10;
This Tab directive controls the description of the result set tab page. The following paragraph describes
all other directives. The other available directives are as follows.
Excel=<Filename>
Predefines the filename when exporting to Excel. You can use environment variables for the
filename. For example:
-- Excel=C:\Excel\test_%date%.xls
CSV=<Filename>
Predefines the filename when exporting in CSV format. You can use environment variables for
the filename. For example:
-- CSV=C:\Excel\test_%date%.csv
49
Controls the number of initially fetched records. Specify All to fetch all records, Page to fetch one
page of records (depends on the window height), or the exact number of records. The following
example will initially fetch 1000 records:
-- Records=1000
Totals=[<Mode>:]<Column>[,<Column>][,<Mode>:<Column>[,<Column>]]
Displays column totals for the given column(s). By default the mode is Sum, but you can also
specify Count, Avg, Min and Max. After specifying a mode you can specify one or more columns
to which it will apply. The following example will display the averages of the sal and comm
columns and the count of the mgr column:
-- Totals=avg:sal,comm,count:mgr
AltRowColor=[<RRGGBB> | <Name>]
Controls the alternate row color. You can specify a name (e.g. Gray) or the hexadecimal RGB
value. The following example displays a light purple alternate row color:
-- AltRowColor=FFEEFF
7.11
If you have created a SQL statement that you wish to re-execute later, you can save it to a SQL Script.
To do so, press the Save button on the toolbar and enter an appropriate filename in the save dialog. The
default extension for a SQL Script is .sql, though you can change the default extension with a
preference described in chapter 20.27. Note that only the current SQL statement is saved to the file, not
the entire history of statements. To include the history in the saved file, right-click on the SQL Window
and select the Save with history item. All statements will be separated with a slash in that case.
You can open a previously saved SQL Script by pressing the Open button on the toolbar and selecting
SQL Script, which will create a new SQL Window. You can alternatively right-click on a previously
created SQL Window and select the Load item, which will open a SQL Script in the existing SQL
Window.
7.12
For most tables and views you will have various standard queries that you frequently need to run. For
example: show all employees that are managers, or show the sum of the salary of all employees,
ordered by department number. You can save such a query as a so called Standard Query, which can
easily be invoked later from the popup menu for the corresponding table or view. This popup menu will
appear when right-clicking on the table or view in the Object Browser or in a PL/SQL or SQL source.
After creating a standard query in the SQL Window, you can press the Save as Standard Query button
on the toolbar of the result grid. The following dialog will appear:
50
You can enter the name of the query, which will be displayed in the popup menu. You can also change
the owner and name of the table or view for which the standard query will be displayed. Press the
Preferences button to change the directory where the standard queries will be stored.
The following information will be saved with the standard query:
Note that you can use substitution variables (see chapter 7.5) to make the standard queries more flexible.
51
8.1
Just like in SQL*Plus, you can type SQL statements across multiple lines, and end a statement with a
semi-colon or slash. You can use the cursor left and right keys to edit the command line, and use the
cursor up and down keys to recall previously entered lines
By entering the edit command, you can use a simple text editor to edit the entire input buffer. After
editing the buffer, you can execute it by entering a slash on the command line. The editor has a history
buffer with all previously executed commands, so that you can quickly execute a modified command.
The status line of the Command Window shows the status of the Echo, Termout, Feedback, Verify,
Autoprint, Heading and Timing options. You can additionally double-click on such an option to change
it between on and off.
52
8.2
To develop a command file with multiple SQL statements and commands, you often need to edit the file,
run it, edit it again, run it again, and so on. To make this a comfortable process, the Command Window
has a built-in editor with SQL, PL/SQL and SQL*Plus syntax highlighting:
8.3
53
Supported commands
Besides all SQL statements, the command window supports the following standard SQL*PLus
commands in this release:
Command
/
? [Keyword]
@[@] [Filename] [Parameter list]
ACC[EPT] Variable [DEF[AULT] Value]
[PROMPT Text | NOPR[OMPT]]
CL[EAR] [SCR[EEN]]
CL[EAR] SQL
COL[UMN] [Column] [Format] [NEW_VALUE
Variable]
CON[NECT] [username/password@database]
[EDITION=edition] [WORKSPACE=workspace]
DEF[INE] [Variable] [ = Text]
DESC[RIBE] Object
DISC[CONNECT]
EDIT
EXEC[UTE] Procedure
EXIT [APPLICATION]
GET [Filename]
HOST [Command]
HELP [Keyword]
PAUSE [Message]
PRI[NT] [Variable]
PROMPT [Text]
QUIT [APPLICATION]
R[UN]
REM[ARK] [Text]
SET AUTOP[RINT] [ON | OFF]
SET COLSEP [Separator | OFF]
SET CON[CAT] [Character | ON | OFF]
SET DEF[INE] [Character | ON | OFF]
SET ECHO [ON | OFF]
SET ESC[APE] [Character | ON | OFF]
SET FEED[BACK] [ON | OFF]
SET HEA[DING] [ON | OFF]
SET LONG [Width]
SET NUM[WIDTH] [Width]
SET PAGES[IZE] [Size]
Meaning
Executes the SQL buffer
Provides SQL help on the keyword
Runs the specified command file, passing the specified
parameters
Allows the user to enter the value of a substitution variable
Clears the screen
Clears the SQL buffer
Defines the format of a column, displays the format of a
column, or displays all column formats
Connects to the database with the specified user and
optionally set an edition and/or workspace
Defines a substitution variable, displays a variable, or
displays all substitution variables.
Gives a description of the specified object
Disconnects from the database
Displays a text editor to edit the SQL buffer
Executes the specified procedure
Quits a running script or closes the Command Window.
Adding the APPLICATION parameter will also close
PL/SQL Developer.
Loads a command file into the editor
Executes the host command
Provides SQL help on the keyword
Displays the message and pauses until the user presses Okay
or Cancel
Displays the value of the bind variable, or all bind variables
Displays the specified text
Quits a running script or closes the Command Window.
Adding the APPLICATION parameter will also close
PL/SQL Developer.
Executes the SQL buffer
A comment line
Determines if bind variables are automatically displayed
after executing a SQL statement or PL/SQL block.
Determines the column separator (default = ).
Determines the character that terminates a substitution
variable reference (default = .)
Determines the character that starts a substitution variable
reference (default = &)
Determines if executed commands in a script are displayed
Determines the character that escapes the character that
starts a substitution variable reference (default = \)
Determines if the number of affected rows of a SQL
statement is displayed
Determines if headings are displayed above the columns of
a result set
Determines the maximum display width of a long column
Determines the maximum display width of a number
column without precision
Determines the number of lines that are displayed for a
result set, before the headings are repeated
54
Command
SET PROMPT [Prompt]
Meaning
Replace the standard SQL> prompt. Instead of a literal text
you can also use the variables [user], [db], or [connection].
Furthermore you can include a bind variable (set
prompt :bind_var_name).
Determines if substitution variables should be scanned
Determines if output of calls to dbms_output.put_line is
displayed, and what the size of the output buffer is. The
value n can be UNLIMITED for unlimited output size.
Determines in which directory spool files are stored if the
SPOOL command does not specify an absolute path.
Determines if output of executed SQL statements is
displayed
Determines if timing information about executed SQL
statements is displayed
Determines if substitution variables are displayed when used
in a SQL statement or PL/SQL block
Displays errors for the previous compilation, or for the
specified object
Displays Oracle release information for the current
connection
Displays the result code of the executed SQL statement
Displays the username of the current connection
Starts or stops spooling and optionally print (OUT). If
Filename has a .zip extension, the spool file will be zipped.
Runs the specified command file, passing the specified
parameters
Stores the values of all options in the filename. You can
execute this file later to restore these options.
Undefines the given substitution variable
Defines a bind variable, displays a bind variable, or displays
all bind variables.
Specify an action whenever an OS error or SQL error
occurs. The action can either be EXIT or CONTINUE,
optionally followed by COMMIT or ROLLBACK.
All of these commands function the same as in SQL*Plus. The following commands are specific to
PL/SQL Developer:
Command
BEAUT[IFY] File | Object
BROWSE Object
EDIT Object
EDITD[ATA] Table | View
EXPORT[DATA] Table
INFO
PROP[ERTIES] Object
QUERY[DATA] Table | View
REC[OMPILE] Object
RUNTEST[SET] TestSetFile [LogFile]
SET BEAUT[IFIERRULES] [File]
SET COL[WIDTH] [Width]
Meaning
Beautifies the specified file or database object, using the
current rules or the rules specified with the SET
BEAUTIFIERRULES command.
Select the Object in the Object Browser
Opens an editable window with the objects definition
Opens a SQL Window for the table or view with an editable
result set
Opens the Export Tool for the specified table
Displays information about the connection
Displays a Property Window for the specified object
Opens a SQL Window for the table or view with a read-only
result set
Recompiles the object
Runs the specified Test Set File in the Test Manager and
logs the result in the Log File.
Temporarily use the beautifier rules from the specified file.
This can be used with the BEAUTIFY command.
Determines the maximum column width in a result set. If
Width = 0, the width is unlimited. The default is 80.
55
56
9.1
The table definition editor has 8 tab pages for various aspects of a table:
Apply Will apply all modifications you have made in the editor to the database.
57
Refresh Retrieves the definition from the database again, discarding any changes you may have
made.
Query Invokes a SQL Window with a query that allows you to view and edit the table data.
View SQL Displays a text editor with the SQL statements that have resulted from the changes
made in the editor. If you have not yet made any changes, it will show the complete creation SQL.
The following chapters will describe the different pages of the table definition editor.
General page
The General page is displayed in the previous chapter, and contains the table owner and name, storage
information, cluster information, and comments. For a new table you can leave all properties empty,
except for the name. All other properties will get a default value:
%Free 10
%Used 40
The default values of the segment properties (initial extent, next extent, %increase, minimum extents
and maximum extents) depend on the corresponding defaults of the tablespace.
The cluster information, storage information, and duration properties are mutually exclusive, because
the cluster implicitly defines the storage characteristics of the table, and temporary tables cannot be
clustered and also have implicit storage characteristics.
If you select External as the organization of the table, storage properties will be disabled, and a new
External tab page will become visible where you can define the external directory and file information.
If you enter or select a cluster name, the storage properties and duration properties will become readonly, and the cluster columns can be entered. Clearing the cluster name has the opposite effect.
If you define the table as temporary, the cluster and storage information will become read-only, and you
can define if rows are preserved after a commit.
If you define an index organization table, you must define a primary key. For a heap organized table
(the default) this is not a requirement.
If you are modifying an existing table, not all properties can be changed. The tablespace, initial extent,
minimum extents, cluster information, duration properties and organization properties cannot be
changed for a table that already exists in the database. If you want to change any of these properties,
you need to check the Recreate table option at the top of the window. As a result, the table will first be
dropped and recreated with the new definition. All data, triggers, and foreign key references will be lost,
so you should be careful when using this option!
58
Columns page
On the Columns page you can view, add, delete, move, and modify the tables columns. If you are
creating an object table, you can also select the object type on this page:
To add a column you can press the Insert column button, or you can start typing the new column
information on the last row (which will create a new, empty last row). The Type column has a
suggestion list for most common data types, but you can also use other data types here. The Default
column requires that you enter a value in the appropriate format, e.g. string values must be quoted.
To delete a column, press the Delete column button. This will either delete the column that currently has
the focus, or it will delete all selected columns. You can select one or more columns by clicking on the
row heading. Dragging the mouse will select a range of rows. Pressing the Control key while clicking
on a row heading allows you to select multiple individual rows.
To move one or more columns, select them as described in the previous paragraph. Now you can click
on one of the selected headings and move the selection to the desired location.
For a virtual column (the email column in the example above) you can enter its expression in the
Default/Expr field. For real columns this field contains the default value.
For existing tables you cannot change the name of existing columns, unless you are using Oracle9.2 or
later. You cannot delete such a column either, unless you are using Oracle8i or later. To overcome these
limitations, you need to check the Recreate table option on the General page. The consequences of this
option are described in the previous chapter.
Note that changing the name of a column will automatically be propagated to the constraint columns,
index columns, and cluster columns.
If you select the type owner and type name at the top of this tab page, you will create an object table,
based on this object type. The column names and types are now defined by and restricted to the toplevel attributes of the object type. You can still define if a column is nullable, the default value, its
storage, and a comment. If you want to change the object type later, you must select the Recreate table
option on the General page.
59
When creating a table you will often add a foreign key constraint and its corresponding columns. By
pressing the Add foreign key columns button you can quickly accomplish this task. Assume that you are
creating a table NOTES that will have a foreign key constraint to the EMP table. On the Columns page
you can press the Add foreign key columns button and select the EMP table and the EMP_PK primary
key constraint to which the foreign key constraint will refer:
After selecting the table and key, enter an optional column prefix for the foreign key columns and the
name of the new foreign key constraint:
60
The foreign key columns will have the same name (+ prefix), data type and comments as the primary
key columns of the referenced table.
To create an identity column (Oracle12c and later) you can press the cell button of the Generated
property. This will display a form where you can enter the generation option (Never, Always, or On
default), as well as the underlying sequence properties used by the Oracle Server:
Keys page
On the Keys page you can view, add, delete, and modify the tables primary, unique and foreign key
constraints:
This grid can be manipulated in the same way as the column grid in the previous chapter. You can add,
delete and modify the key constraints. Moving the constraints will not have any effect, as they are not
really ordered.
Note that the storage information of the underlying index that is used to enforce a primary or unique key
constraint is not defined on this page. If the constraint is enabled, there will automatically be a
corresponding index on the Indexes page with the same name. For this index you can define the storage
definition. Disabling or deleting a primary or unique key constraint will implicitly delete the underlying
index.
61
The Type column has a list that allows you to select just the Primary, Unique or Foreign key type. You
can quickly select the correct type by typing the first character (P, U or F). Note that a table can only
have one primary key constraint, and the default value for this column (Primary or Unique) depends on
this. Changing the type will affect the Referencing table, Referencing columns and Cascade columns, as
they are only valid for foreign key constraints. Changing the type to Foreign will also implicitly delete
the index.
To define the Columns to which the constraint applies, you can simply type the column names in the
appropriate cell (separated by commas), or press the cell button. This will invoke a column selection
screen where you can easily add, remove or move (reorder) the key columns:
For foreign key constraints you can type or select a Referencing table. Doing so will automatically
select default Referencing columns, based on the primary and unique key constraints of this table. The
selection list for this column shows all column sets that make up primary or unique key constraints for
the referencing table, and are therefore the only candidates here. In the On Delete listbox you can define
what action should be performed for the records in the child table when the parent record is deleted. The
Set null action is supported in Oracle8i and later.
If you are using Oracle8, you can additionally define if the constraint is deferrable, and if it is initially
deferred. These 2 options are obviously related: you cannot have a non-deferrable constraint that is
initially deferred.
62
Checks page
On the Checks page you can view, add, delete, and modify the tables check constraints:
This grid can be manipulated in the same way as the column grid. You can add, delete and modify the
check constraints.
The Condition column should contain the boolean expression that must be true (or null) for all rows in
the table. You cannot apply a check constraint if one or more rows violate the condition, unless you also
uncheck the Enable option. The check constraint can be enabled after correcting the violating rows.
If you are using Oracle8 or later, you can additionally define if the constraint is deferrable, and if it is
initially deferred. These 2 options are obviously related: you cannot have a non-deferrable constraint
that is initially deferred.
63
Indexes page
On the Indexes page you can view, add, delete, and modify the tables indexes:
This grid can be manipulated in the same way as the column grid. You can add, delete and modify the
indexes.
The Owner of the index can be left empty, the default owner is the user that is currently logged on. If
you want to use a different owner for the index, just select it from the list.
The Type of the index can be Normal, Unique, or Bitmap. The last index type is only available on
Oracle7.3 Servers and later. Note that you can only create a unique index if the index columns of each
row in the database are indeed unique. As long as this is not the case, you cannot apply this index to the
database.
To define the Columns that you want the table to be indexed by, you can simply type the column names
in the appropriate cell (separated by commas), or press the cell button. This will invoke a column
selection screen where you can easily add, remove or order the index columns.
For function based indexes you can specify the functions, separated by commas. For descending
indexes, you can follow the column name by DESC.
You can additionally enable key compression for the index, including the number of prefix columns to
compress, and define the index as a reverse index.
If the index is for a primary or unique key then the owner, name, type, and columns cannot be modified.
These properties are all derived from the key constraint. Changing the name of the key constraint will
automatically change the name of the corresponding index, changing the constraint columns will change
the corresponding columns for the index. The owner will always be the same as the owner of the table,
and the type of the index will always be unique.
64
The Storage parameters can be defined or viewed by pressing the cell button. This will invoke a storage
editor:
For new indexes you do not need to enter any of this information, as each property has a default value:
%Free 10
The default values of the segment properties (initial extent, next extent, %increase, minimum extents
and maximum extents) depend on the corresponding defaults of the tablespace. The %Used property
does not apply to indexes.
Note that if you modify the %free, initial extent, and minimum extents properties of an existing index,
this will implicate that the index (and constraint) will be dropped and recreated to apply this change. For
large indexes, this may be time consuming.
65
Privileges page
On the Privileges page you can grant/revoke privileges on the table to/from users and roles:
This grid can be manipulated in the same way as the column grid. You can add, delete and modify a
grantee. Deleting a grantee is equivalent to revoking all individual privileges.
The Grantee is the user or role to which you want to grant certain privileges. Note that privileges
granted to a role will often not suffice for the purpose of development of stored program units. If a user
is granted select privilege on a table through a role, and references this table in a stored program unit,
compilation will fail because the table is unknown. The user must personally be granted select privilege
if the object is to be used in a program unit that he or she owns.
The individual privilege columns can have 3 values:
Grantable The grantee has the privilege, and can grant it to other users or roles
The Select, Insert, Update and Delete privileges allow the grantee to perform this action on the records
of the table. The References privilege allows the grantee to create a foreign key to this table. The Alter
privilege allows the grantee to alter the table definition with the alter table command. The Index
privilege allows the grantee to create an index on the table.
66
Partitions page
The Partitions page is only visible when you (re)create a table, or when you edit an existing partitioned
table:
At the top of the page you can select Range, Hash, or List partitioning, as well as the partition columns.
In the grid you can define the name, column values (if applicable), and storage of each partition. If you
have defined more than one partition column, you must separate the values by a comma.
For Range partitions you can additionally define subpartitions on an additional Subpartitions tab page.
67
Triggers page
This page shows all triggers defined for the table:
You can add a trigger by pressing the New trigger button. This will invoke the corresponding template
for creating a trigger, which will subsequently open in a Program Window. After compilation, the
trigger will become visible on the Triggers page.
To delete a trigger, press the Delete trigger button. To enable or disable a trigger, click on the Enabled
checkbox. Press the View SQL button to see the drop/enable/disable trigger statements and all other
changes made to the table.
To view or edit the trigger source, double-click on the trigger in the list or press the Edit trigger button.
This will open a Program Window for the selected trigger.
68
External page
If the organization of the table is defined as External on the general page, this tab page will become
visible:
Here you can set the access driver type and the external data properties that define the external table.
69
You can save the SQL to a file, copy it to the clipboard, or open it in a Command Window with the
corresponding buttons at the upper right corner of the window. The Print button on the toolbar will print
the SQL. You can additionally make changes to the SQL and apply the changed SQL. After applying
the changed SQL, the window will return to form mode and will refresh the table definition. Changes
made to the SQL will immediately be reflected in the forms.
If you press the View SQL button again, the window will return to form mode, discarding any unapplied
changes you may have made to the SQL.
If you selected the View option in the Object Browser to view the table definition, the View SQL button
will display the creation SQL for the table, without preceding it with a drop command. This way you
can save a table definition in a file, or copy its definition to another database or user.
70
9.2
Most properties have a default value, and you only need to supply a name when creating a new
sequence:
Minimum value 1
Initial value 1
Increment by 1
Cache size 20
Cycle Off
Order Off
9.3
The default value for the Owner will be the user that is currently logged on. Checking the Public option
will create a public synonym, and will make the Owner field read-only. The Object owner and Object
name fields have a suggestion list to easily select a translation object for the synonym. If the Object
owner field is empty, the Object name list will display all objects.
9.4
71
The default value for the Owner will be the user that is currently logged on, and you can use the
suggestion list to create a library with a different owner. The Filespec is the full file specification of the
3GL library that you want to use. If you are developing on the database server, then you can use the
Select DLL file button to select the dynamic link library. Otherwise you have to type the name of the
DLL (Windows) or shared object (UNIX). The validity of the Filespec is not checked.
9.5
The directory editor allows you to easily create or modify a directory, which can subsequently be used
for BFILEs:
If you are developing on the database server, then you can use the Select directory button to select the
directory path. The validity of the directory path is not checked.
72
9.6
Creating a new job is equivalent to calling dbms_job.submit. Modifying an existing job is equivalent to
calling dbms_job.change. For more information about jobs, see the DBMS_JOB chapter in the Oracle
Supplied Packages Reference manual.
The Open PL/SQL Editor button next to the What field invokes a more convenient PL/SQL Editor with
syntax highlighting, Code Assistant, and so on.
9.7
For the queue table name you can select an existing queue table, or you can press the Create button to
create a new queue table (see chapter 9.8).
For more information about Oracle's Advanced Queuing, see the following Oracle documentation:
9.8
73
The queue table editor allows you to create or modify an advanced queue table:
On the General tab page you can define the name, storage parameters, and comment for the table. On
the Priviliges tab page you can grant privileges on the table to users and roles. See also chapter 9.1.
On the Queue page you can supply the queue table specific information. For the payload type you can
select an existing object type, or RAW to create a raw queue.
For more information about Oracle's Advanced Queuing, see the following Oracle documentation:
74
9.9
The user editor allows you to create or modify a user, its privileges, and tablespace quotas:
Note that you need specific system privileges (such as provided by the DBA role) to view and modify
user information.
General page
On the general page you basically only need to enter the name and password. All other properties have a
default value:
Profile DEFAULT
If you modify an existing user, the current password will not be displayed. Enter a new password to
change it, or leave it empty to leave the password unchanged. If the user is identified externally, you
cannot enter a password.
75
This page allows you to view and modify the object privileges granted to the user. This does not include
the privileges that are indirectly granted through a role.
In the first column you can see the object on which privileges are granted to the user. All other columns
represent a specific privilege. Each privilege can have the following value:
Grantable The user has the privilege, and can grant it to other users or roles
This page displays the roles that are granted to the user. Each role privilege can be grantable, so that the
user can grant it to other users and roles. If a role privilege is default, the role will be enabled when the
user logs on. If it is not default, the role privilege must explicitly be enabled for the session by executing
a set role command after the user has logged on.
76
This page displays the system privileges that are granted to the user. Each system privilege can be
grantable, so that the user can grant it to other users and roles.
Quotas page
This page displays the tablespace quotas of the user. You can enter a maximum number of bytes,
kilobyes, or megabytes that the user can allocate in a tablespace, or you can specify that the quota is
unlimited.
9.10
77
The role editor allows you to create or modify a role and its privileges:
By default a role does not need to be identified. You can also define password identification or external
identification for a role. Password identification requires that you enter a password, and is useful if the
role is not granted by default to users. Such a role needs to be explicitly set after a user logs on, which
requires the password.
The other 3 tab pages (Object privileges, Role privileges and System privileges) work in the same way
as the corresponding pages of the User definition function.
78
9.11
The profile editor allows you to edit the resource limits, password limits, and users of a profile:
Each limit can be set to Default, in which case the value will be inherited from the standard profile
DEFAULT, to Unlimited, or to a concrete value.
On the Users tab page you can define to which users this profile applies. Note that if you remove a user
from the profile, it will implicitly be changed to the DEFAULT profile.
9.12
The database link editor allows you to create and edit a database link:
Note that the Password and the Authenticated By properties will not be retrieved when you edit an
existing database link. You will have to enter this information every time you edit the database link.
79
On the left side you see folders for the scheduler object types, as well as a folder for running jobs and
job runs. Window groups, Windows and Job classes are system wide, and are displayed immediately in
the root of the corresponding folder. Schedules, Programs, Chains and Jobs are owned by specific
users, so that each folder contains subfolders for the owners.
On the upper right side you see the properties of the selected object, and additional object details are
displayed on the lower right side. When creating or editing objects, you can enter the information here.
80
Schedules
A schedule specifies when and how many times a job is run. Schedules can be shared by multiple jobs.
For example, the end of a business quarter may be a common time frame for many jobs. Instead of
having to define an end-of-quarter schedule each time a new job is defined, you can point to a named
schedule.
Schedules can be of type Calendar, allowing you to specify a repeat interval as shown above, or Event,
which allows you to assign a queue and condition:
81
Windows
Windows can be used to automatically start jobs or to change resource allocation among jobs during
various time periods of the day, week, and so on. A window is represented by an interval of time with a
well-defined beginning and end, such as "from 12am-6am".
You can explicitly enter the individual schedule properties for the window. This is called an inline
schedule. You can alternatively select an existing schedule for the window. All schedule properties will
be displayed italic, indicating that they refer to the selected schedule. If you override one or more
schedule properties, the selected schedule will be cleared, and you will have defined an inline schedule
instead. This allows you to use an existing schedule as a template.
In the bottom section you can add or remove window group membership for the current window by
checking or unchecking the corresponding option.
82
Window groups
Window groups can be created for ease of use when scheduling jobs. If a job must run during multiple
time periods throughout the day, week, and so on, you can create a window for each time period, and
then add the windows to a window group. You can then set the schedule of the job to this window
group, and the job executes during all the time periods specified in the window group.
To add or remove member windows, simply check or uncheck the corresponding option in the Member
windows section at the bottom of the screen.
Job classes
Job classes provide a way to assign the same set of attribute values to member jobs, or to set service
affinity for member jobs. You can grant execute privileges to other users or roles that need to use this
job class. To revoke a privilege, right-click on it and select Delete from the popup menu.
83
Programs
A program describes what is to be run by the Scheduler. A program includes an action like the name of
a stored procedure, the name of an executable found in the OS file system, or the text of a PL/SQL
anonymous block.
A program is a separate entity from a job. A job runs at a certain time or because a certain event
occurred, and invokes a certain program. Jobs can be created that point a program, which means that
different jobs can use the same program and run the program at different times and with different
settings. Given the right privileges, different users can thus use the same program without having to
redefine it. This enables the creation of program libraries, where users can select from a list of existing
programs.
A program can define arguments if the stored procedure or external executable that is references accepts
these arguments. In the Arguments section you can define these arguments. To delete an argument,
right-click on it and select Delete from the popup menu.
To grant Execute or Alter privileges for the program to other users and roles, go to the Privileges section.
To revoke a privilege, right-click on the privilege and select Delete from the popup menu.
Chains
Chains allow multiple dependent steps to be linked together through a set of rules. Steps can be of type
Program, Event schedule, or Inline event. You can subsequently create jobs to run these chains.
84
Jobs
Jobs associate a program with a schedule (or a window or window group), and are the principal object
that you work with in the Scheduler. You can create multiple jobs that refer to the same program but
that run at different schedules. A job can override the default values of program arguments, so multiple
jobs can refer to the same program but provide different argument values.
You specify the job action by specifying program unit, external executable, or PL/SQL Block to run.
This is known as specifying the job action inline. You can alternatively select an existing scheduler
program or chain.
You can explicitly enter the individual schedule properties for the job. This is called an inline schedule.
You can alternatively select an existing schedule for the job. All schedule properties will be displayed
italic, indicating that they refer to the selected schedule. If you override one or more schedule
properties, the selected schedule will be cleared, and you will have defined an inline schedule instead.
This allows you to use an existing schedule as a template.
To grant Alter privileges for the job to other users and roles, go to the Privileges section. To revoke a
privilege, right-click on the privilege and select Delete from the popup menu.
You can view details and logs of finished job runs on the corresponding tab page in the bottom section
of the screen.
10.1
85
Creating objects
To create a new object, right-click on the corresponding folder and select New from the popup menu.
Now you can enter the properties and additional detail information on the right side of the screen. When
you are done, press the Apply button to create the object in the database. To view the SQL for the object
creation, press the View SQL button. To cancel the object creation, press the Cancel button.
10.2
Editing objects
To edit an existing object, select it in the folder on the left side of the screen and edit the properties and
additional detail information on the right side of the screen. When you are done, press the Apply button
to modify the object in the database. To view the SQL for the object modification, press the View SQL
button. If you have not made any changes, the object creation SQL will be displayed. To cancel the
changes, press the Cancel button.
10.3
Deleting objects
To delete an object, select it in the folder on the left side of the screen and select Drop from the popup
menu. After confirmation the object will be permanently deleted from the database.
10.4
To view information about job runs that have finished execution, you can open the Job runs folder.
Here you will see a number of predefined reports, such as All, Failed, and so on. Click on a report to see
the job run details that match the criteria from the report:
The job runs can be sorted by clicking on the sort button of a column header. Columns can be moved by
dragging & dropping the header(s).
You can copy job run information to the clipboard by selecting a range of rows, columns, or cells, rightclicking on them, and selecting Copy Comma Separated or Copy Tab Separated from the popup menu.
If you do not select a range, the entire report will be copied.
To refresh the report contents, press the Refresh button at the bottom of the screen.
86
At the top you can supply a logical name for the report.
In the bottom section you can define how the sys.all_scheduler_job_run_details view will be queried
for the report. See the Oracle Database Reference guide for more information about this view. The field
selection list to the right can be used to quickly select fields. Double-click on a field to apply it to the
currently selected section on the left.
The Field list allows you to select the fields that will be displayed in the report. This is a comma
separated list. You can also enter an asterisk in the field list to include all fields.
The Where clause allows you to define which job runs will be displayed in the report. For example, to
create a report that displays all succeeded job runs from today, use a where clause like this:
log_date >= trunc(sysdate) and status = 'SUCCEEDED'
The Order by clause allows you to define a list of fields by which the job runs will be ordered.
On the Conditions tab page you can define the display color of job runs that meet a certain condition:
The condition can be any valid SQL expression. For the Color property you can select either the text or
the background.
To edit or delete a report, right-click on it and select the corresponding item from the popup menu.
10.5
To view information about currently running jobs, click on the Running jobs folder. The right side of
the screen will show information about the currently running jobs.
87
11. Diagrams
The Diagram Window allows you to create a graphical representation of a selection of objects. This way
you can easily visualize (a part of) the database objects of your application or project and their relations:
You can add all relevant object types to a diagram, and include the relations between them. Foreign key
references between tables are automatically included. Dependency references between objects can also
be automatically added. For large diagrams you can add additional structure by including object groups.
A diagram can be used for documentation purposes, but can also serve as a workspace. Right-clicking
on an object provides access to all object functions, and double-clicking on an object will invoke the
default action for the object type.
11.1
Creating a diagram
To create a new diagram, select the Diagram Window from the New submenu in the File menu. An
empty Diagram Window will appear. To add a database object to the diagram, drag it from the Object
Browser into the Diagram Window. You can drag & drop multiple objects at once.
To move a diagram object, click on the title bar and drag it to the new location. To resize a diagram
object you can drag an edge or a corner. To delete an object from the diagram, press on the X at the
upper-right of the object. This will only affect the diagram, and the database object will not be dropped.
88
By default all items will be displayed, but if you right-click on an object and select Set as default, the
visible items will apply to all objects added to a diagram in the future. You can do this for all object
types.
Sorting items
You can sort all items by right-clicking on the diagram object and selecting Order as created or Order
alphabetically from the Items submenu. You can also explicitly drag & drop an item to place it at a
different position.
Adding relations
To add a relation between 2 objects, click on the icon of an element of the source object, and drag it to
the element of the target object. A line will be drawn between the 2 elements of the objects. You can
move the line to another element by selecting the line and moving the selection point up or down. To
remove a line, select it and press the Delete key.
If you add a table to a diagram, foreign key relations with other tables on the diagram will automatically
be included. These relations can be deleted if necessary.
If an object references other objects, or is referenced by other objects, you can right-click on the object
and select Reference links from the popup menu. You can subsequently select which references you
want to include in the diagram. For example, if you right-click on the employee package and select
Reference links, you can see that it references the DEPT and EMP tables:
By default relations will be drawn as straight lines. You can add additional bends by right-clicking on a
line and selecting Insert bend from the popup menu. You can also hold down the Ctrl key while
clicking on a line to insert a bend. A new selection point is added to the line as a result.
To change the line end, right-click on the end of the line and select Change line end from the popup
menu. Here you can select a symbol for one-to-many relations, optional relations, and arrows.
To change the color, size, and label of a line, right-click on it and select Line properties from the popup
menu:
89
The label will move with the line if objects are moved.
Adding groups
To add additional structure to a large diagram, you can create object groups. Groups can have
distinctive colors, and can have a title at the upper or lower left or right:
To add a group, right click at an empty position on the diagram and select New group from the popup
menu. A new group will appear at this location, which you can resize to appropriate dimensions. All
objects that are completely covered by the group will implicitly be part of that group, and moving the
group will also move these enclosed objects. If you hold down the Ctrl key while moving a group, the
enclosed objects will not be moved.
90
To change the appearance of a group, right-click on it and select the Properties item from the popup
menu. You can also double-click on the group. The following screen will appear:
You can change the font, fill color, line color and line size of the group, make the group transparent, and
make it automatically resize based on the text. You can optionally enter the title of the group, and
specify the location of the title.
If groups are visually overlapping, you can right-click on a group and select Send to back or Bring to
front from the popup menu.
To create a default group appearance, right-click on it and select Set as default. This will apply to all
groups added to a diagram in the future.
To delete a group from the diagram, select it and press the Delete key. This will only delete the group,
and not the enclosed objects.
Adding notes
You can add text notes to the diagram by right-clicking at the desired location on the diagram and
selecting New note from the popup menu:
As you can see, the properties for a note are the same as for a group, but with different default values.
To create a default note appearance, right-click on it and select Set as default. This will apply to all
notes added to a diagram in the future.
Aligning items
You can quickly align items by right-clicking on them and selecting Align to grid from the popup menu.
This will place the selected item on an 8 pixel grid. To align all items, right-click on the diagram and
select Align all to grid from the popup menu, or press the corresponding button on the Diagram
Window toolbar.
11.2
91
Zooming
You can zoom in and out on the diagram by right-clicking on the diagram and using the Zoom item
from the popup menu, or by using the corresponding button on the Diagram Window toolbar. You can
zoom in by 150% or 200%, or you can zoom out from 90% to 10%.
11.3
To save a diagram to a file, select the Save item from the File menu. A diagram will be saved in a file
with a .pdd extension, which can be reopened later. To define a standard location for diagram files, go
to the Directories preference page and set the corresponding option.
11.4
Updating a diagram
A diagram is a static representation of the database. If database objects change over time, you will need
to update the diagram to reflect these changes. To do so, right-click on a diagram object and select
Update from DB from the popup menu. To update all objects on the diagram, right-click on it and select
Update All from DB. You can also press the corresponding button on the Diagram Window toolbar.
If an object is dropped from the database, you will also need to delete it from the diagram. If an object is
renamed in the database, you will need to delete the diagram object and add it with the new name.
11.5
Printing a diagram
To print a diagram, click on the Print button on main toolbar. To print the current view you can press
the Print view button on the Diagram Window toolbar. The page orientation will automatically be
determined when printing the current view.
The page size can be controlled by using the Page size button on the Diagram Window toolbar. Set it to
Automatic to automatically determine an appropriate size. Set it to Manual to manually control the page
size. For large diagrams you can now zoom out and move the horizontal and vertical page ends to an
appropriate location, or move diagram objects so that they do not span multiple pages.
11.6
Exporting a diagram
You can export a diagram to an image file by right-clicking on it and selecting Save as image from the
popup menu. You can subsequently select the file format (bmp, jpg, wmf or emf).
You can also copy the diagram image to the clipboard by right-clicking on it and selecting Copy as
image from the popup menu.
92
12. Reports
To run reports against your application data or against the Oracle dictionary, you can use PL/SQL
Developers built-in Report functionality. There are a number of standard reports, and you can easily
create your own custom reports. These custom reports can be saved in a report file, which can in turn be
included in the reports menu. This makes it very easy to run your own frequently used custom reports.
12.1
Standard reports
The standard reports are accessible through the Reports main menu. If, for example, you select the
Compilation errors report, you will first be prompted for the object type, owner, and name for which
you want to display the current compilation errors:
After entering the appropriate values and pressing the OK button, the report will be displayed:
The result is an HTML document that is displayed by PL/SQL Developers internal HTML viewer or
by the Internet Explorer ActiveX control, depending on the preferences (see chapter 20.10).
You can subsequently print the report by pressing the Print button on the toolbar, or you can save the
report in HTML format by pressing the Save results button on the right side of the Report Window. The
Copy as HTML button copies the report results to the clipboard. The Export Results button allows you
to export the results in CSV, TSV or XML format, or to export the results directly to Excel.
The Edit report button provides access to the report definition, if the report is not locked.
You can right-click on the results for additional options.
12.2
93
Custom reports
Custom reports are very easy to create. First you create a new, empty report by pressing the New button
on the toolbar, and selecting the Report Window item from the popup menu. An empty Report Window
will appear:
In the SQL editor you can type a single SQL select statement for your report. For master/detail reports
you can use a join select statement (this will be described later). Lets start simple with the well-known
emp table by typing the select statement and pressing the Execute button on the toolbar:
This is a very basic report, with only the default style properties applied. The following chapters
describe how you can refine the reports functionality.
94
12.3
Variables
Very often your reports will require some additional input before they can run. Lets assume that you
want to restrict the report from the previous chapter to the employees of just one department. In that
case you need supply a substitution variable in the SQL text:
select * from emp
where deptno = &department
order by ename
When this report is run, the user is prompted for a department before the select statement is executed.
This is of course not very foolproof. What if the user enters nothing? The statement would lead to a
ORA-00936: missing expression exception. What if the user enters a value that is not a number? Or a
number that does not exist in the dept table? To prevent these situations, you can use the parameter
options described in the following chapters. These options must be specified between brackets, just like
attributes in an HTML or XML document.
Name option
The name of a variable is used as a prompt in the variable input form. Therefore you should make sure
that it describes the meaning of the variable. The name is the only option that does not have to be
specified between brackets, if it is the only option. If the name contains spaces or other special
characters, enclose it in double quotes. The following 2 examples are equivalent:
select * from emp
where deptno = &Department number
order by ename
and
select * from emp
where deptno = &<name=Department number>
order by ename
Hint option
Besides the name option, you can additionally specify a hint text. This hint will be displayed on the
status line of the variable input form when this variable has the focus:
select * from emp
where deptno = &<name=Department number
hint=Only employees from this department will be listed>
order by ename
Type option
The type option restricts the user to the information that can be entered, and also controls how the value
should be inserted into the resulting SQL text:
select * from emp
where deptno = &<name=Department number
type=integer>
order by ename
In this situation the user can only enter values that are valid integer values. The entered value will be
replaced in the SQL text as is. For strings however, you would want the value to be enclosed in quotes.
Consider the following select statement:
select * from emp
where ename = &<name=Employee name
type=string>
If you enter SCOTT (without quotes) in the variable input form, the resulting SQL would be:
select * from emp
where ename = SCOTT
95
Valid types are: none, string, integer, float, and date. No validation will occur for date values, so that
the user can additionally supply date expressions like sysdate, trunc(sysdate, MM) and so on.
Required option
If you require a value for a certain variable, set its required option to yes or true:
select * from emp
where deptno = &<name=Department number
required=yes>
order by ename
Now the report can only be run if a value is specified for the department number.
Default option
To present a default value for the variable, specify the default option:
select * from emp
where deptno = &<name=Department number
default=10>
order by ename
The default value can also be a select statement. This select statement should return just one row with
one column. For example:
select * from emp
where deptno = &<name=Department number
default=select min(deptno) from dept>
order by ename
In this case the default value will be the smallest department number.
Ifempty option
As an alternative to making a variable required or providing a default value, you can specify the ifempty
value in case the user does not specify one:
select * from emp
where ename like &<name=Employee name
type=string
ifempty=%>
If the user does not specify a value, the percent sign will be used, and all employees will be retrieved.
This option cannot be specified together with the required option.
Uppercase/Lowercase option
If you have a string variable and want to implicitly convert its value to uppercase or lowercase, set its
uppercase or lowercase option to yes or true:
select * from emp
where ename = &<name=Employee name
type=string
uppercase=yes>
The value is displayed as typed, but is converted to uppercase or lowercase in the resulting SQL text.
Readonly option
A variable can be defined as read-only by specifying readonly=yes. The user can see the variable and
its value, but cannot change it.
Hidden option
You can hide variable by specifying hidden=yes.
96
List option
The list option provides the user with a list of possible values. You can specify a comma-separated list
of items:
select * from emp
where deptno = &<name=Department number
list=10, 20, 30, 40>
order by ename
This allows the user to select one of the four items, or to type a different value. In this case it makes
more sense to use a select statement though:
select * from emp
where deptno = &<name=Department number
list=select deptno from dept order by deptno>
order by ename
Each item is now followed by a description, and the description option is added. The list will only
display the descriptions, but the actual value will be used in the resulting SQL text.
Again you can do the same with a select statement with 2 fields:
select * from emp
where deptno = &<name=Department number
list=select deptno, dname from dept order by dname
description=yes>
order by ename
To restrict the user to just the items in the list, specify the restricted option:
select * from emp
where deptno = &<name=Department number
list=select deptno, dname from dept order by dname
description=yes
restricted=yes>
order by ename
Now the user can only select values from the list, and cannot enter any other value by hand.
To create a multi-select list, you can specify the multiselect option:
select * from emp
where deptno in (&<name=Department number
list=select deptno, dname from dept order by dname
description=yes
multiselect=yes>)
order by ename
Now the user can select multiple departments by description. You will need to use a field in (&variable)
syntax to construct a select statement that returns the records that match the selection.
The items in a list can sometimes depend on the value of another variable. Imagine that you want to
create a report that shows all columns of a specific table. A table is identified by the owner and the
name. For the owner you can use a list of all users in the database. For the table name you can query the
all_tables view for the selected owner:
97
As you can see, the select statement for the second (table) list refers to the first variable through
the :owner bind variable. Whenever the value of the owner is changed, the table list will be populated.
Note that the name of the bind variable cannot be longer than 30 characters, and cannot contain spaces
or other special characters. Spaces in the variable name will be converted to underscores. If the variable
name had been Owner of the table, then the bind variable would have been :owner_of_the_table.
Also note that if the value of a variable is empty, the dependent list will also be empty. No query will be
performed in this situation.
Checkbox option
If the user can select one of two distinct possibilities, you can use the checkbox option. This option
needs to be followed by the checked and unchecked values:
select * from emp
order by hiredate &<name=Descending sort order
checkbox=desc, asc>
Even though you must always specify 2 values, one of the values can be empty:
select * from emp
order by hiredate &<name=Descending sort order
checkbox=desc,>
Since the default sort order is ascending, these 2 examples are equivalent.
If no value is specified for this variable, the result will be empty as well:
select * from emp
Note the spaces after the prefix and before the suffix. These are important, because the prefix, value and
suffix are concatenated exactly as specified!
98
Lines option
This option controls the number of lines (default = 1) on the variable entry form for multi-line text:
select sum(sal) as saltotal,
&<name=Notes type=string lines=4> as notes
from emp
Editor option
This option will add a button to the variable entry field that opens a text editor to edit the value. You
can specify the syntax highlighting as Plain (no highlighting), SQL or XML:
select sum(sal) as saltotal,
&<name=Notes type=string lines=4 editor=plain> as notes
from emp
Escape character
If you wish to use an ampersand in the SQL text that should not be interpreted as a substitution variable,
use a double ampersand instead. The following example will retrieve all employees from the R&D
department:
select * from emp
where emp.deptno in (select dept.deptno from dept
where dname = 'R&&D')
order by empno desc
If the text 'R&D' had been used instead, you would have been prompted for the D variable.
12.4
After opening a new Report Window, typing a select statement, and executing the report, the layout will
use the default style properties. It will have a simple tabular layout, with standard font properties, table
style, colors, and so on. To refine the standard layout, switch to the Layout tab page. For a new report,
this page will look as follows:
99
As you can see, you can define various layout properties for all layout items (the report title, variables,
tables, and the fields). If you want to define properties for an individual field, you first need to press the
Refresh Fieldlist button on the toolbar:
Now all fields of the result set of the select statement will be included in the layout grid, and you can set
the layout properties of each individual field. If you leave the Style, Header or Align property of a field
empty, the corresponding property from the Default Field will be used.
After changing a layout property, you can execute the report again to view the effect this has on the
results. You can alternatively enable the Auto Update option on the toolbar, in which case each change
will immediately be reflected in the results.
The following chapters describe the various layout properties in detail.
Displayed
The checkbox in the leftmost column of the layout grid indicates if the layout item should be displayed
or not. This allows you to suppress the report title or variables, and
allows you to control whether a specific field should be displayed
or not.
Description
The description of the Report Title will be displayed at the top of
the report and after each page break. The description of the
Variables will be displayed above the variables.
For the individual fields you can define a description to override
the standard field name. This description will be used for the
header of the column.
Style
The style controls the appearance of the layout items. Press the
cell button (...) to bring up the style editor:
In the listbox at the top of the style editor you can see all standard
styles, and a Custom style. You can select a standard style from
the Style Library (see chapter 12.5), or you can select the custom
100
style so that you can change the various style properties for the current layout item.
Note that this style system is based on the Cascading Style Sheets (CSS) standard. The properties that
you see in the style editor are the ones that you will most frequently use, but you can also add other CSS
properties and values below the standard properties. You can, for example, add a Height style property
with a value of 20pt to set the cell height to 20 points. See http://www.w3.org/TR/REC-CSS2 for more
information about Cascading Style Sheets.
The Copy and Paste buttons allow you to copy the properties of a style, so that you quickly derive a
new style from an existing one.
If you define nothing for the field styles, the Default Field style from the Style Library will be used.
You can override this by defining the style of the Default Field layout item. You can override this
default style at the field level by specifying the corresponding style. Note that each field header inherits
its style properties from the Default Header style, so you only need to override the properties that you
want to change. If, for example, you define the Default Field style as Verdana, 14 points, blue, and you
want to display the EMPNO column in Verdana, 14 points, red, you only need to define the color at the
EMPNO level. The font family and font size will automatically be inherited from the Default Field level.
The default styles of the various layout item types are described in chapter 12.5.
Header
Just like you can set the style for the data of the individual fields, you can also set the style for their
headers. If you define nothing, the Default Field Header style from the Style Library will be used. You
can override this by defining the style of the Default Header layout item. You can override this default
style at the field level by specifying the corresponding header style. Note that each field header inherits
its style properties from the Default Header style, so you only need to override the properties that you
want to change.
Align
You can align the layout items in the following ways:
Note that you can also set the Text Alignment style property for a layout item. This will take precedence
over the alignment option you can specify in the layout grid. Also note that the effect of the alignment
may depend on the Width style property of the layout item.
Format
By default the format of a field is controlled by the data type, scale, and precision. Very often you will
use calculated fields or aggregated fields, in which case the scale and precision are unknown. In these
situations you can specify a format.
The Format property only has effect for date and number fields. For number fields you can use a 9 for a
zero-suppressed digit, 0 for a normal digit, G for a thousand separator, D for a decimal separator, and E
for scientific notation. You can additionally specify literal text in double or single quotes. Some
examples:
Format
999G990D00
9G990
0000
0%
0D000e+00
0D000e-0
Value = 1234
1,234.00
1,234
1234
1234%
1.234e+03
1.234e3
101
Value = 5
5.00
5
0005
5%
5.000e+00
5.000e0
Value = 0.1
0.10
0
0000
0%
1.000e-01
1.000e-1
For date fields you can use the standard Windows date and time formats.
102
Break
The break layout property allows you to structure your report results. Assume that you want to display
the departments and their employees. You can specify the following query for this:
select d.*, e.*
from
emp e, dept d
where e.deptno = d.deptno
order by d.deptno, e.empno
By specifying a Break on the LOC column, you will get some more structure into your report:
Repeating values for the fields up to (and including) LOC will be suppressed. In short: each dept record
will only be displayed once. In this case it is necessary that the records are sorted by department (the
DEPTNO column). If you want to repeat the header after each break, use the Break + Header option.
103
You can have multiple breaks for a report. The order by clause of the query must assure that the result
set is sorted on all break columns.
Sum
The sum property allows you include a sum for a field:
You can specify that the sum is to be calculated at the break level, at the report level, or both.
104
Page headers
To define a page header, you first need to set the page size (see chapter 12.6). The Report Title will be
repeated after each page break, and can include the following variables:
To include such a variable in the page header, precede it with an ampersand. For example:
All employees (&dbuser@&database)
If you run the report connected as user scott to database chicago, the header will look as follows:
All employees (scott@chicago)
Since the report is formatted as HTML, you can additionally include HTML code. To include an image,
you could include the <img> tag:
All employees <img src=logo.gif>
To include left aligned, centered, and right-aligned information, you can use a single-row table with 3
cells, and include the information in the corresponding cell:
<table width="100%"> <tr> <td>&dbuser</td> <td align="center">All
Employees</td> <td align="right">&page</td> </tr> </table>
All Employees
Note that you can use these variables and HTML code in the description of all layout items, but they are
most useful for the Report Title.
12.5
105
Instead of defining and redefining the same styles over and over again, you can press the Style Library
button on the toolbar to create and modify your standard styles. If, for example, you would like all fields
that contain SQL expressions to be displayed in Courier New, 12 points, blue, simply define a SQL style
with these properties in the library and apply it where appropriate.
There are a number of style names that have a special meaning:
Style name
Default Report Title
Default Variables
Default Tabular Tables
Default Form Tables
Default Field Style
Default Field Header
Description
Will be applied to the report title
Will be applied to the variables
Will be applied to all tabular tables (e.g. detail records)
Will be applied to all form tables (e.g. master records)
Will be applied to all fields that do not have a defined style
Will be applied to all field headers that do not have a defined style
These are default styles, so you can override them in an individual report by defining the style for the
corresponding layout item.
Note that all used styles (standard and custom) are stored in the report file. When a report is run and a
style needs to be applied, PL/SQL Developer will try to locate it in the in the style library. When it is
not available, the style from the report file will be used. This will ensure that your report will always
display correctly but that styles can still be overruled.
12.6
Options
Connect Parameters
The Connect Parameters determine how the report query will be run. If, for example, it is necessary that
your report is executed under the SYS account, you can enter this name in the Username field. You can
additionally enter the Password, or you can leave it empty. If you leave it empty, you will be prompted
for the password when the report is executed. You can also specify the Database, if the report should
106
always be executed in the same database instance. You can alternatively enter * in the database field,
which indicates that the report should be executed in the current database.
The Use this connection option allows you to disable or enable the Connect Parameters for a report. If it
is disabled, the current PL/SQL Developer connection will be used.
Security
The Security options allow you to lock the report definition (the SQL, Layout, and Options), so that a
user cannot view or change it. This may be useful if the Connect Parameters specify a privileged
account (such as SYS) with password. If a user can change the SQL, he or she could execute any
statement under the SYS account if the report is not locked.
The Security can be set to one of the following values:
Locked for other users You can only change the report definition if you know the reports
Password, or if you are connected in PL/SQL Developer with the same account as specified in the
Connect Parameters.
Locked for all users You are always prompted for the reports Password before you can change
the report definition, regardless how you are currently connected in PL/SQL Developer.
If the report is locked, the report file (.rep) is encrypted so that is cannot be viewed or changed with a
text editor.
Layout options
Form layout By default all records are displayed in tabular layout, except for master records,
which are displayed in form layout. By enabling this option, all records will be displayed in form
layout. This may be useful if each record has many and/or wide fields, that cannot be displayed on
a single line.
Left margin The number of pixels for the left margin of the report. This option only works if you
are using the Internet Explorer as HTML viewer.
Top margin The number of pixels for the top margin of the report. This option only works if you
are using the Internet Explorer as HTML viewer.
Page break The number of lines after which a page break should occur. The report header will
be repeated after each page break.
Only NBSP When enabled, all spaces in the data will be converted to NBSPs (non-breaking
spaces) in the HTML output. When disabled, normal spaces will be used. This can affect the
layout, because HTML viewers will display consecutive spaces as one space.
Include SQL When enabled, the SQL text of the report is included in the HTML output.
Other options
Background image The image (.jpg or .gif) that should be displayed in the background of this
report. You can use the Select file button to find your image file.
Background color The color that should be displayed in the background of this report.
12.7
107
By default the Reports menu item is included in the main menu, and contains only the standard reports.
These standard reports are located in the Reports subdirectory of the PL/SQL Developer installation
directory. The menu is simply a representation of this directory structure. Selecting an item from the
reports menu will execute that report.
You can add or remove reports in this directory, but you can also configure the reports menu through
the Configure Reports item in the Tools menu. This will bring up the following dialog:
The Default Report directory option indicates whether the Reports menu should include the Reports
subdirectory from PL/SQL Developer installation directory. This directory contains the standard reports.
The edit field below this option contains a list of directories that should be included. You can type
directories manually, or you can select a directory by pressing the Add directory to list button on the
right.
Note that the report files and subdirectories will be merged in the Reports menu. You should try to
prevent duplicate subdirectory and report filenames within this directory list, otherwise you will get
ambiguous menu items in the Report menu.
The Style Library is also accessible from within this report configuration dialog (see chapter 12.5).
108
13. Graphics
To quickly display a graphical representation of column data queried in a SQL Window or Report
Window, you can use the Graph Window. Consider the following query in a SQL Window:
To see a graph of the salaries of the department you can press the Graph button:
The same button is available on the Report Window. It will either start the Graph Wizard as described
below, or you can select a pre-defined graph style or template, and appropriate columns will be selected
for the X and Y axis.
The Graph Wizard will first allow you to select the data for the X-axis:
This shows all columns and an [Index] item, which is useful if you dont have an X-axis value but want
to display data on the Y-axis in order of occurrence. In this case we want to display the salary by
department number, so we select DEPTNO and press the Next button to select the data for the Y-axis:
109
After selecting SALARY for the Y-axis, you can press Next to select various graph style properties:
Rotate Press the left mouse button and move the mouse to rotate the graph around the X and Y
axis.
Move Press the left mouse button and move the mouse to move the graph across the window.
This function is always available by pressing the right mouse button, regardless of the activated
toolbar function.
Zoom Press the left mouse button and move the mouse to zoom in to and out of the graph.
Depth Press the left mouse button and move the mouse to increase or decrease the depth of the
graph.
Save as template Saves the layout of the graph as a template for future graphs based on the same
column names. If you create a graph later and select From template from the Graph button popup
menu, then the layout information from this template will be used.
You can additionally print a graph or copy it to the clipboard by pressing the corresponding buttons on
the main toolbar.
110
14. Projects
To organize your work you can use PL/SQL Developers built-in project concept. A project consists of
a collection of source files, database objects, notes, and options. It allows you to work within the scope
of a specific set of items, instead of a complete database or schema. This makes it easy to find the
project items you need, to compile all project items, or to move a project from one location or database
to another.
A project keeps track of your desktop configuration. If you reopen a project, all items that were opened
when the project was previously closed will be opened at the same position. The AutoSave Desktop
preference must be enabled for this. This information is not stored in the project definition file
(Project.prj), but in the project desktop file (Project.dsk)
Note: to work with projects, the Use Projects preference must be enabled. If this is not the case, the
main menu will not contain the Project item. For all project menu items there are also corresponding
toolbar buttons, which can be added by right-clicking on the toolbar and enabling the Project group.
14.1
To create a new project, select the New item from the Project menu. This will bring up the Project
Options dialog:
On the General page you can define how you want to connect when this project is opened. You can also
define if you want to continue project compilation after a compilation error has occurred. The
Preferences section allows you to control whether or not the project has its own folder history when
opening and saving files and its own File Browser (see chapter 19). When disabled the general folder
history and File Browser will be used.
The Items page allows you to view the project items. This can be source files of PL/SQL program units,
Test Scripts, SQL Scripts, Reports, and so on. A project item can also be an object that is stored in the
database, and that does not have a representation in a source file. Project items can also include other
files such as MS Word documents, HTML documents, and so on. When the project is first created, the
item list will be empty.
The Notes page allows you to maintain project notes. These notes can contain anything, such as a to-do
list, project decisions, design, and so on.
The To-Do items tab page shows the to-do items for the source files of the project. See chapter 15 for
more information about to-do items.
14.2
111
Saving a project
After setting the options, you can save the project by selecting the Save item from the Project menu.
This will create a project file with the extension .prj. The project file contains the item specifications,
the options, and the notes. Therefore you need to save a project whenever you add or remove an item,
when you change an option, or when you change the notes.
Saving a project will not implicitly save the source files that are included in the project.
14.3
14.4
To add a database object to the project, right-click on it in the Object Browser and select the Add to
Project item from the popup menu. Just like with Program Files, a PL/SQL program unit will implicitly
be enabled for compilation. Other objects, such as tables and sequences, cannot be compiled.
You can alternatively drag & drop a database object from the Object Browser to the Project Items
Window (see below).
If the current user owns the database object, the owner will not be saved in the project file. If another
user owns the object, the owner will be saved as part of the object specification. This makes the project
portable from one user to another.
112
14.5
After adding items to the project, you can select Project Items from the Project menu to work with the
project items. The Project Items Window may look something like this:
The first 4 Program Files are enabled for compilation. The 2 Test Scripts, the SQL script, and the tables
and sequences are not enabled for compilation.
You can keep the Project Items Window open at all times to have quick and easy access to all project
items. This window is part of the project desktop, and will implicitly be reopened when the project is
reopened.
To edit an item, you can simply double-click on it. If the item is a source file, it will be opened in a
corresponding window (Program Window, Test Window, and so on). If the item is a database object,
the appropriate editor will opened with the object definition. If an item is an external file, the
corresponding application will be launched (e.g. Acrobat Reader for a PDF file).
You can alternatively right-click on an item to bring up the popup menu as displayed above. Here you
can disable/enable the item for compilation, or you can remove the item from the project. If the item is a
database object, you will also have access to the object popup menu for that object as a submenu.
To change the order of the project items, you can click on the row header and drag it to the new location.
The order is not only visually important, but also determines the order of compilation.
To search for text in the contents of the project items, you can press the Find in Project button on the
project items toolbar, or use the Find item from the Project menu.
Item groups
You can use item groups to organize project items for larger projects. You can use these groups for
limited build and make operations, to limit searches, to open/close all items, and in general to get a
better overview. Items can only belong to one group, and will additionally belong to the special group
named All.
To switch between item groups you can select the corresponding tab page above the item list. Initially
there will only be a group named All. This is a special group that contains all items. To add a group,
right-click on a group tab page, select Add Group, and provide a name for the group. You can rename,
delete or move a group by right-clicking on its tab page and selecting the corresponding item from the
popup menu.
113
To move an item to a group, right-click on it, select Move to group, and select the group from the
submenu. If you select None, the item will subsequently only belong to the All group. When adding a
new project item, it will implicitly be moved to the currently selected group.
14.6
Compiling a project
To compile a project, you can select the Build or Make item from the Project menu.
The Build function will simply compile all project items for the currently selected group that are
enabled for compilation. The items will be compiled in the order as they appear in the project item list.
If the compilation of an item fails, the project option Halt after first error determines if the project
compilation will continue or not:
The Make function will only compile those items that have been changed since the previous compilation.
If a PL/SQL Program Unit is included as a database object, and it is invalid in the database, it will also
be recompiled. The timestamp of the compilation is stored in the projects desktop file. Items that are
enabled for compilation but are up-to-date, will be listed as Skipped in the compilation progress window.
114
In this example you can see the comment in the source file (starting with the text TODO:) and the ToDo Item editor where you can enter the text, priority, category, owner, creation date, and close date. The
contents of the selection lists for the priority, category and owner fields can be defined through a
preference (see chapter 20.24).
To-Do Items can be accessed through the To-Do Item editor, which is a convenient way to create, edit,
view or delete a To-Do Item. You can also edit the comment directly in the source file, as long as you
do not change the format.
Because the To-Do Items are stored as comment in the source file, they will always correspond with the
actual status of the source. Regardless whether the source comes from the database, from the file
system, or is an old version from a version control system.
115
To access all To-Do Items for a specific source file you can invoke the To-Do List:
Here you can quickly find a To-Do Item and locate it in the source file by pressing the Goto button.
The To-Do List can be sorted by clicking on the column header.
Right-click on the list to copy, print, or export the To-Do Items.
15.1
To create a To-Do Item, you first need to place the cursor at an appropriate location in the source file.
This is where the comment will be inserted, so it is important that this is near the location where the
work needs to be done. Next you can right-click at this location and select Add Item from the To-Do
Items submenu from the popup menu:
The To-Do Item editor mentioned above will appear, and you can enter the information for the new ToDo Item. After pressing the OK button the comment will be inserted at the exact cursor location.
15.2
To edit an existing To-Do item, you can either right-click on the corresponding comment in the source
file and select Edit Item from the To-Do Items submenu, or select the Show List item if you are not
currently near the To-Do Item you want to edit. In that case you can select the To-Do Item from the list
and press the Edit button or double-click it.
Now you can changes the various properties of the To-Do Item and press the OK button to update the
comment in the source file.
116
15.3
A To-Do Item can be closed by right-clicking on the comment in the source file and selecting Close
Item from the To-Do Items submenu. Alternatively you can invoke the To-Do Item editor and press the
Close button.
15.4
A To-Do Item can be deleted by right-clicking on the comment in the source file and selecting Delete
Item from the To-Do Items submenu. Alternatively you can invoke the To-Do Item editor and press the
Delete button.
You can also simply delete the comment from the source file.
117
16.1
At the top of the Connection List you see a button to refresh the list, to expand and collapse the tree
view, and a button to define folders and connections (see chapter 16.2).
The first items in the Connection List are the user-defined folders. These folders can hold connections
that are explicitly defined in the folder, and/or connections that are implicitly added as a result of the
criteria of the folder. The Recent folder shows all connections that you have recently used.
Each connection can have a grey color if it is implicitly added or a user-defined color if it has been
explicitly defined. Under each connection you can view and manipulate the windows that have a
corresponding database session.
The key icon behind each connection shows the status of the connection:
The password for the connection is known, and there are one or more database sessions for the
connection.
The password for the connection is known, and there are no database sessions for the connection.
The password for the connection is unknown. When trying to connect you will be prompted for
the password.
118
Connection functions
Right-clicking on a connection will show the following popup menu:
The first 6 items allow you to open windows for the selected connection. For example, if you want
to run a report using a specific connection, right-click on it, click on the Reports menu item, and
select a report from the submenu. The New Instance item will open a new PL/SQL Developer
instance for the selected connection.
The Show All Windows item will display windows that belong to the selected connection, and will
minimize all windows that belong to other connections.
The Close All Windows item will close all windows that belong to the selected connection.
The Reconnect All Windows item allows you to select a connection to which all windows of the
current connection will be reassigned.
The Connect item will make a connection to the database. If the password is unknown you will
first be prompted.
The Connect as Main item will make the selected connection the main connection. You can also
double-click on a connection to make it the main connection.
The Disconnect item will log off all sessions associated to the selected connection. This includes
all windows for the connection.
The Remove item is only enabled for implicitly created connections. It allows you to clean up the
Recent folder for connections that you do not frequently use.
The Add to Folder item allows you to add an implicitly created connection to the Connection List.
The new connection will be added to the root of the Connection List, after which you can set its
properties and move it to an appropriate folder.
Folder functions
Right-clicking on a folder will show the following popup menu:
The Show All Windows item will display windows that belong to the connections of the selected
folder, and will minimize all windows that belong to other connections.
119
The Close All Windows item will close all windows that belong to the connections of the selected
folder.
The Reconnect All Windows item allows you to select a connection to which all windows of the
connections within the current folder will be reassigned.
Window functions
Right-clicking on a window will show the following popup menu:
From this popup menu you can activate, close, and resize the window to a normal or minimized state.
You can change the connection of a window by selecting it from the Reconnect submenu.
Furthermore you can rename a window. This can be useful if you just created a new window and want
to provide a meaningful name instead of, for example, SQL Window New.
The Short Text item will switch to shorter descriptions. For example, the description Program Window
- employee.pck will be shortened to P - employee.pck.
To execute a window, you can select the Execute menu item.
120
16.2
To define your own folders and connections you can select the Define Connections item from the Tools
menu or press the Define Connections button at the top of the Connection List. The following dialog
will appear:
At the right you can see buttons to create a new connection, to create a new folder, to delete the selected
connection or folder, to move it up or down. You can also move an item by dragging & dropping.
The last 2 buttons can be used to export and import all connection definitions.
121
Defining a folder
To define a folder, press on the New Folder button and enter the information in the section below. For
example:
The Name and Image from the Display section will be displayed in the Connection List.
The Username, Database, and Connect as fields can be used to implicitly show connections in the
folder. For the example above all connections made to the chicago database will implicitly be shown in
the Chicago folder. You can use * and ? wildcard characters for the Username and Database fields.
Specifying sys* for the Username will implicitly show all connections for usernames that begin with sys.
If you leave these fields empty, connections need to explicitly be added to the folder.
The Edition and Workspace properties can be used to show connections for the given edition and
workspace.
A newly created folder will be created under the selected folder. To create a folder in the root of the
Connection List you can hold down the Alt key while pressing the New Folder button.
To copy an existing folder you can select the folder and hold down the Ctrl key while pressing the New
Folder button.
122
Defining a connection
To define a connection, press on the New Connection button and enter the information in the section
below. For example:
The Name and Image from the Display section will be displayed in the Connection List.
The Username, Database, Password, Connect as and Identified externally fields can be used to define
the logon information for the connection. If you leave the Password empty, you will be prompted for
the password whenever the connection is used for the first time in a PL/SQL Developer instance.
The Edition property can be used to set an edition if you are using Edition Based Redefinition.
Whenever this connection is used, the given edition is set for the session. Note that this property is casesensitive.
The Workspace property can be used to set a workspace if you are using Workspace Management.
Whenever this connection is used, the given workspace is set for the session by calling
DBMS_WM.GotoWorkspace. Note that this property is case-sensitive.
A newly created connection will be created under the selected folder. To create a connection in the root
of the Connection List you can hold down the Alt key while pressing the New Connection button.
To copy an existing connection you can select the connection and hold down the Ctrl key while
pressing the New Connection button.
On the Initialization tab page you can enter a SQL script that will be executed for each session that is
created for this connection. Separate multiple statements with semi-colons, and terminate PL/SQL
blocks with a slash.
On the Message tab page you can enter a message that will be displayed when you log on for this
connection.
After defining the connection and its initialization script you can press the Test button to verify that all
properties are correct.
123
17.1
The main connection is used for all functions in PL/SQL Developer where you do not explicitly select a
connection. For example, when opening a new SQL Window and executing a query, you will implicitly
create a database session for the main connection. The Object Browser will also use the main
connection.
After logging on in PL/SQL Developer you have implicitly set the main connection. The main
connection can be changed by using the Session > Log on function again, or by double-clicking on a
connection in the Connection List. In the Connection List the main connection is displayed in bold.
You can also set the main connection by using the Set Main Connection or Set Main Connection to
<current> items from the Session menu. The first allows you to select a connection from a sub menu,
and the second will use the connection from the current window.
17.2
Window connections
All windows can be for different connections, and will show the connection at the bottom left in the
status bar. After opening a new window from the main menu, it will use the main connection. You can
change the connection of a window by clicking on it and selecting a different connection from the list:
Window connections can either be pinned or unpinned. When unpinned ( ), the window connection
will follow the main connection when the main connection is changed. When pinned ( ), the window
connection will remain the same when the main connection is changed. To view or change the pinning
of the window connection, view or click on the button in the connection status panel.
124
Newly created windows can either be pinned or unpinned by default, depending on the corresponding
preference (see chapter 20.1). If you explicitly change an unpinned window connection, it will
subsequently be pinned.
If you select the Disconnect item from the popup menu, the database session(s) will be disconnected
and the windows will no longer be associated with the connection.
17.3
Session mode
Multi-threading implies that you need a multi-session environment. After all, the Oracle Server can only
execute one statement at a time for any given database session. Things can only run simultaneously if
they run in different sessions. Not all development environments allow for an unlimited amount of
sessions, so that a preference can be set (see chapter 20.2) that controls the amount of sessions that
PL/SQL Developer will use. This preference is called the Session mode, and can have one of the
following values:
Multi session - Each Test Window, SQL Window and Command Window will have its own
session, and another session will be used for compilations. This is the most flexible setting, and
will obviously lead to the largest amount of database sessions. Another possible disadvantage is
that updates in Window X will only be visible in Window Y after they are committed.
Dual session - The Test Windows, SQL Windows and Command Windows belonging to the same
connection will share one session, and another session will be used for compilations.
Disadvantage of this mode is that only one window can execute at a time for a given connection.
Single session - All windows and all compilations for the same connection will use the same
session, making transaction management difficult. The debugger is disabled in this mode. Only
use this setting if you are restricted to using one database session.
17.4
When you execute a Test Window, SQL Window or Command Window in Multi session or Dual
session mode, the Break button on the toolbar will be enabled so that you can break execution at any
time. A break may not always be successful, for example in case of a locking situation. In that case you
can resort to the Kill item in the Session menu, if you are privileged to do so.
If you move the mouse cursor of a currently executing window, its shape will change to indicate that it
is executing and you cannot make any modifications to the contents of that window.
After execution is finished, the Commit and Rollback button will be enabled if a transaction has been
started. In Multi session mode, each window has its own session, and therefore also has its own
transaction. The Commit and Rollback button will reflect the transaction status of the topmost window.
125
Et cetera...
All this information is available in the Oracle dictionary and accessible from within PL/SQL Developer
by using the Object Browser.
18.1
You can make the Object Browser available by selecting the Object Browser item in the Tools menu.
The Object Browser shows all base object types in the database for the main connection that are
relevant to developing program units. You can navigate through this tree view in the same way that you
use the Explorer in Windows to navigate through folders. Opening the Tables folder displays all tables
that are accessible by the current session. Opening a specific table folder shows all relevant properties
of this table. Opening the Foreign keys folder under a table displays all foreign keys for this table, and
so on. The Recent objects folder contains all objects that you have recently used in PL/SQL Developer.
Whenever you open a folder, the information queried from the
dictionary is read into memory to make subsequent accesses as quickly
as possible. To force the Object Browser to re-query this information
after something has changed, you need to select the modified object
and press the Refresh button at the upper left side of the window. You
can also refresh an object by selecting the corresponding item from the
popup menu. To refresh the entire Browser, press the Ctrl key when
pressing the Refresh button.
You can drag and drop objects from the Object Browser into the
workspace. This will bring up an editor with the object definition. You
can set a preference to control exactly what function should be
performed (see chapter 20.11).
You can also drag and drop an object from the Object Browser into an
editor. This will bring up a popup menu, whose contents depend on the
object. You can select to copy the name (prefixed by the owner if
necessary), properties, description, and other relevant text into the
editor, at the location where you drop it. If you drag and drop a folder
into an editor, all object names in the folder will be copied. These
object names will be comma separated. You can set a preference to
control if the object names are placed on one line or on multiple lines
(see chapter 20.12).
By pressing the right mouse button on an object icon, a context
sensitive popup menu appears that allows you to perform other
functions on this object. The functions from this popup menu are
described in the following paragraphs.
126
You can select multiple objects by using the Control or Shift key during selection. If multiple objects
are selected, the object popup menu will show only those items that are applicable to all selected objects,
and the drag and drop function will work on all objects simultaneously.
You can press Ctrl - and Ctrl + to quickly align the width of the Object Browser with the contents.
The Object Browser preferences (see chapter 20.11) allow you to define which folders are visible, and
in which order they are displayed. It also allows you to define the maximum number of objects that can
be visible in the Recent objects folder. Furthermore you can define the double-click action for a browser
object. By default this will expand the corresponding node, but you can also define that this will bring
up the object definition editor, or the properties window.
Filtering objects
To limit the number of object in the Object Browser, you can use the User selector and Filter selector at
the top of the Object Browser. You can also perform ad hoc filtering by entering an expression in the
filter field.
When selecting a user, only the objects owned by that user will be displayed. Select <CURRENT
USER> to see only the objects owned by the currently connected Oracle user. Select <ALL USERS> to
see objects owned by any user. Note that this can degrade performance when opening a folder.
Select a filter to limit the objects to those that meet specific criteria. The filter also defines the sort order
of objects within a folder. See chapter 18.2 on how to create your own filters.
In addition to these filter definitions you can also enter an ad hoc expression in the filter field. The most
basic filter is by object name, which can be specified without any additional syntax. For example, if you
enter DEPT in the filter field, the Object Browser will be limited to objects with DEPT in the name.
You can further refine the filter by adding % wildcard character. For example, if you enter DEPT% in
the filter field, only objects that start with DEPT will be displayed.
For more complex filter expressions you can press the [] button next to the filter field to invoke the
Browser filter options form:
Name Objects with a name that contains this text will be included. You can add the % wildcard
character to refine the filer. The filter expression is Name=<text>.
Source Objects where this text occurs in the PL/SQL source will be included. Objects that do no
not have a PL/SQL source (e.g. tables, views, sequences) will implicitly be included as well. The
filter expression is Source=<text>.
Status Objects with this status (valid or invalid) will be included. The filter expression is
Status=<valid/invalid>.
Created after Objects created after this date will be included. The filter expression is
CreatedAfter=<date>.
Created before Objects created before this date will be included. The filter expression is
CreatedBefore=<date>.
Modified after Objects modified after this date will be included. The filter expression is
ModifiedAfter=<date>.
Modified before Objects modified before this date will be included. The filter expression is
ModifiedBefore=<date>.
127
For the example above the Object Browser will include valid objects that have the word DeptRecord in
their PL/SQL source code. After entering the filter options in the form and clicking on the Apply button,
the Object Browser will be updated and the filter field above the Object Browser will contain the filter
expression. In this case: Source=DeptRecord Status=Valid. You can subsequently modify the
expression directly in the filter field, or indirectly through the filter options form.
Duplicate an object
You can duplicate a table, sequence or synonym by selecting the Duplicate item from the popup menu.
This will invoke an editor window with all properties of the selected object, except for the name. This
can be useful if you want to create a similar table to perform some tests on.
The properties are displayed in a modal window that you can place anywhere on the screen. You can
keep a property window visible (it will stay on top of other windows) and continue editing in another
window. You can additionally roll-up and roll-down the window by pressing the button on the upper-
128
right of the window. This way you can easily make space for other things, and keep the properties
available.
You can select rows, columns or ranges of cells in a description window. To select rows or columns,
just click on the row heading or column heading and drag the mouse pointer to highlight the selection.
To select a specific range of cells, move the mouse pointer over the left edge of a cell until its shape
changes, press the mouse button, and drag the mouse to highlight the selection. The selection can be
copied or printed. To make a comma delimited copy of the selected cells, right-click on the window and
select the corresponding item from the popup menu. To export the description to a CSV, TSV, HTML
or XML-file, select the corresponding item from the Export submenu. To print the contents of a
description window, select the Print item.
By double-clicking on a cell in a description window, the contents of the cell will be copied into the
editor of the topmost window.
To sort the rows in a description window, press the heading button of the column on which you want
the rows to be sorted.
129
Renaming an object
Tables, views, sequences and synonyms can be renamed by selecting the Rename item from the popup
menu. If you are using Oracle 9.2 or later you can also rename columns. A dialog will appear with the
old name, which you can modify and apply.
Dropping an object
Sometimes it is necessary to drop an object. It may have become obsolete, or must be changed from one
type to another (e.g. from a function to a procedure). To accomplish this, just select the Drop item from
the popup menu.
Recompiling an object
Objects often reference other objects in the database. Whenever these referenced objects change, the
referencing object can become invalid. In this case a red mark is displayed in the icon of this object. To
recompile an invalid object, select the Recompile item from the popup menu. If compilation succeeds,
the mark disappears. If compilation fails, you can view the errors by selecting the View item from the
popup menu.
130
On this screen you can see the current flags of the program unit. You can also change the values of flags,
rename flags, add new flags, and delete existing flags. Press the Apply button to apply these changes to
the database object. Note that this will cause an implicit recompilation of the program unit, and can
cause it to become invalid.
131
Exporting tables
To export the definition and data of a table, select the Export data item. This will bring up the Export
Tables tool for the selected table. See chapter 21.4 for details.
Running a job
For jobs, submitted through the dbms_job package, you can explicitly run it by selecting the Run item
from the popup menu.
132
18.2
You can define filters that determine which objects are visible in the system folders of the Object
Browser, and in which order these objects are displayed. A select list is located at the top of the Object
Browser that allows you to quickly switch between the various filters.
Object Browser Filters can be defined by selecting the Object Browser Filters item in the Tools menu or
by pressing the Filters button above the Object Browser. You can modify, create and delete filters in
this dialog:
Description.
This description shows up in the select list at the top of the Object Browser.
User.
Defines for which Oracle user this filter is valid. If you leave this field empty, the filter will be
valid for all Oracle users. If you specify a user and database (e.g. scott@chicago), the filter will
only be visible if you are logged on as this user and database.
Default.
If you check this option, the selected filter will be the activated when you start PL/SQL Developer.
You can define a default filter for each user. The default filters are displayed in bold.
Where clause.
A filter defines a select statement on the all_objects (or dba_objects) view. The where clause can
be used to restrict the result set of this select statement. You can use the following columns:
object_type - the type of the object (TABLE, VIEW, PACKAGE, and so on)
last_ddl_time - the date/time that the object was most recently compiled
18.3
133
Order by clause.
Use the columns from the all_objects view to order the objects in the Object Browser.
The folders of the Object Browser can be customized in several ways. You can change the order of the
folders in the Object Browser, the color of each folder, a folder hierarchy, and you can hide specific
folders based on your current connection.
You can also define your own folders and populate them with objects. You can either explicitly add
specific objects to a folder, or define a query to populate it, or a combination of both. The query will be
executed when the folder is opened in the Object Browser.
Browser Filters can be defined by selecting the Object Browser Folders item in the Tools menu or by
pressing the Folders button above the Object Browser. You can modify, create and delete folders in this
dialog:
At the top of this dialog you see all folders and their hierarchy. A red color indicates a system folder, a
black color indicates a user defined folder. Some restrictions apply to system folders.
To the right of the folder list you have 4 buttons available to add a new folder at the position of the
currently selected folder, to delete a folder, or to move it up or down in the list. The order in the Object
Browser is the same as the order in this list.
At the bottom you can change the definition of the currently selected folder:
Color Select the color of the folder. Subfolders of objects in this folder will inherit the same
color.
134
Visible Disable this option to make the folder invisible in the Object Browser. This can be used
to hide specific system folders, and overrides the Connection option.
Description The description of the folder in the Object Browser. Cannot be changed for system
folders.
Connection Defines for which Oracle users this folder will be displayed. If you leave this option
empty, the folder will be displayed for all Oracle users. If you specify a user and database (e.g.
scott@chicago), the folder will only be visible if you are logged on as this user and database. You
can use ? and * wildcard characters to match multiple users. For example *@prd for all users in
the prd database.
Parent To hierarchically place a folder within another folder, you can select its parent from the
list. To clear the parent, press the Clear button.
Suppress owner When enabled, the Object Browser will not display the owner of the objects in
this folder. This is primarily useful for folders where the owner is known from the context (for
example: Scotts tables and views).
Where clause The where clause can be used for query based folders to restrict the selection of
objects. In the example above, the where clause is set to status = INVALID to populate the
folder contents with all invalid objects.
Order By clause The order by clause can be used for query based folders to define the sort
order of the selected objects.
Objects For manual folders you can define list of objects. You can place an object on each line
in an owner.name format. For example: SCOTT.EMP. Note that it is usually more convenient to
add an individual object from the Object Browser by right-clicking on it and selecting Add to
folder from the popup menu.
The where clause and order by clause can include any SQL expression and any column from the
all_objects view. This works the same as for Browser Filters. See chapter 18.2 for more details.
Note that filters do not affect the object contents of user defined folders.
135
From the File Browser tree you can access files and directories from user-defined locations on the local
computer or on the network. You can quickly open, save, rename, and delete files here.
You can use the File Browser as a docked or floating tool. See chapter 28 for more information about
dockable tools. By default the File Browser is located on the second tab page of the docking area of the
Object Browser.
136
19.1
When the File Browser is first displayed, it will initially be empty. To populate the File Browser, you
must first define one or more File Browser Locations. To do so, select File Browser Locations from the
Tools menu, or press the Locations button at the top of the File Browser. The following screen will
appear:
Each location you define here is displayed in the root of the File Browser tree. For each location you
can define the following properties:
Path The local or network path where the files and directories are located. The File Browser tree
will display files and directories from this starting point.
Include subdirectories When enabled, subdirectories from the path will be displayed in the File
Browser tree and can be traversed.
Include file filter One or more file filter expressions to explicitly include in the File Browser
tree. Separate multiple filter expressions with a semi-colon (e.g. *.sql; *.cmd). If this property is
omitted, all files will be included.
Exclude file filter One or more file filter expressions to explicitly exclude in the File Browser
tree. Separate multiple filter expressions with a semi-colon (e.g. *.tmp; *.dat). If this property is
omitted, no files will be excluded. By default this property will exclude files.info and *.~*. The
first excludes a PL/SQL Developer system file that contains file state information, and the second
excludes PL/SQL Developer backup files.
Description The description of the location that is displayed in the File Browser tree.
Color The color of the icon of the location and its subdirectories in the File Browser tree.
Parent The parent location of this location. When selected, this location will not be displayed in
the root of the File Browser tree, but as a sub location of the parent location.
You can create, delete and sort the locations by using the corresponding buttons to the right of the list.
19.2
137
After you have defined your File Browser Locations, the File Browser will display all your files,
subdirectories and sub locations in a tree view. Double-clicking on an file will open it in the work area
in edit mode. Right-clicking on a file will show the following popup menu:
Open If the current item is a file, it will be opened in edit mode. If the current item is a directory
or location, the tree view node will be expanded.
Open as Shows a submenu where you can open the current file as a Program Window, SQL
Window, or Command Window.
Open in Explorer Opens the Windows Explorer for the selected file or directory.
Save window in name Saves the contents of the current (topmost) window in the currently
selected directory or location. This allows you to quickly save the contents at the selected location,
regardless of its origins (newly created, from the database, or from elsewhere on the file system).
Save window as filename Saves the contents of the current (topmost) window as the
currently selected file. Note: this will replace the contents of the current file.
Info This submenu shows the full path, timestamp, and size of the current file.
Properties Shows the properties of the file or directory. The properties dialog additionally
allows you to set attributes and permissions.
Read-only files will be marked with a red sign in the file icon (Department.spc and Employees.spc in
the example above).
If files are created, deleted or renamed by other tools than PL/SQL Developer, the File Browser will
automatically update its contents.
138
20. Preferences
The Preferences tool allows you to set various preferences for PL/SQL Developer. When you select this
item, the following dialog appears:
At the left you can select a preference page from one of the 6 categories (Oracle, User Interface,
Window Types, Tools, Files, and Other).
At the top you can select a preference set, which defines a set of preferences at a certain level. By
default you will define personal preferences for your Windows user (in the screenshot above for the
user Mark), but you can also define personal preferences for a specific Oracle connection. Whenever
you use such a connection to logon to the database, the corresponding preference set will be used.
Furthermore your system administrator can define default preferences at a global level and at Oracle
connection levels. For detailed information about preference sets, see chapter 20.33.
Below the preference sets you see the preferences for the currently selected preference page (in the
screenshot above for the Oracle Connection page). For each preference you will see the current value.
A green indicator to the left of the preference indicates that the value is set in the current preference set.
If the indicator is black, the value is inherited from a different set (hold the mouse cursor over the
indicator to view the preference set name). To revert a preference to its inherited value (in other words:
remove it from the current preference set), you can click on the green indicator.
At the bottom of the preference form you can press OK to confirm the changes, Cancel the changes,
Apply so that you can preview the changes to any visual preferences, or press the Import/Export button
to export the preferences to a file or import them from a file.
The following chapters will describe each preference page in detail.
20.1
139
Oracle Connection
Session mode.
Controls how many separate database sessions PL/SQL Developer will use. This feature is
described in detail in chapter 17.
Check Connection.
When this option is enabled, PL/SQL Developer checks every 60 seconds if your database
connection is still alive. If your session is killed or the server is shutdown, PL/SQL Developer will
automatically logoff.
Oracle Home.
By default PL/SQL Developer will use the Primary Oracle Home on your PC. You can define the
Primary Oracle Home with the Oracle Home Selector (a standard Oracle utility). You can force
PL/SQL Developer to use a specific Oracle Home by selecting one from this list.
OCI Library.
PL/SQL Developer will use the most recent version of SQL*Net or Net8 that is installed. If this
version of SQL*Net or Net8 causes problems, you can force PL/SQL Developer to use another
version. The DLL name will be something like ora72.dll (SQL*Net 2.2), ora73.dll (SQL*Net 2.3),
oci.dll (Net8 8.1.x), and so on. These DLL's are located in Oracle's bin directory.
140
20.2
Oracle Options
141
Automatic statistics.
This option controls if a statistic report is to be generated for every executed SQL Statement and
Test Script. If you disable this option, the statistic report will be empty. By pressing the Select...
button, a list opens up with all statistics available in the database that you are currently connected
to. You can select which statistic you wish to include in a statistic report. If you do not have
access to the dynamic performance tables, the Select... button will be disabled.
Unicode enabled.
When selected, Unicode data will be fetched as such from the Oracle Server, and displayed as
Unicode text. When disabled, Unicode data from the server will be converted to the character set
of the Oracle Client, in accordance with the NLS_LANG key of the Oracle Home Registry.
142
20.3
Oracle Compiler
This preference page allows you to control various options for the PL/SQL Compiler of the Program
Window. See the Oracle Database Reference guide for more information about these options.
PL/Scope identifier.
This option controls the compile time collection, cross reference, and storage of PL/SQL source
code identifier data. When set to None, this disables collection of identifier data. When set to All,
this enables the collection of all source code identifier data.
143
information about conditional compilation, see the PL/SQL Language Reference Guide. If you
leave this section empty, the default flags for the database instance will be used. Press the Reset to
default flags button to get the default flags for database instance.
PL/SQL Warnings.
In this section you can define how the compiler treats specific warning exceptions or specific
severity categories. For each exception number or category you can define if it is Disabled (no
warning message), treated as a Warning (successful compilation with a warning message), or
treated as an Error (failed compilation with a error message). You can specify multiple exception
numbers, separated by commas.
Note that the order of the warnings is relevant: items at the bottom of the list take precedence over
items at the top. Therefore you should first specify actions for the categories, and then actions for
specific exceptions.
20.4
Oracle Debugger
144
20.5
Oracle Output
Enabled.
In SQL Windows and Test Windows, calls to dbms_output.put_line will be buffered and displayed
after execution of the script. This preference can be overruled on the output page of each
individual SQL Window and Test Window.
145
Buffer size.
The size in bytes of the dbms_output buffer. If more than this number of bytes is output during
one execution, an exception will occur. Set the value to 0 for an unlimited buffer size.
20.6
Oracle Trace
These preferences control the Trace page of the Test Window (see chapter 5.11). You can control which
columns from the trace table should be displayed, and in which order.
20.7
Oracle Profiler
These preferences control the Profiler page of the Test Window (see chapter 6.3).
Columns.
Controls which columns from the profile table should be displayed, and in which order.
146
Time units.
Defines the unit of the Total time, Maximum time, Minimum time and Average time columns.
Show 0 Occurrences.
Determines if a reported source line with 0 execution occurrences will be displayed.
20.8
147
If you enable the Store History preference, PL/SQL Developer will store the username, password and
database information in the Logon history. When you restart PL/SQL Developer later, the logon dialog
allows you to quickly select a previously used account:
For security reasons you may not want to store passwords in the history, even though PL/SQL
Developer encrypts them. This would imply that anyone could connect to the database with your
accounts if they have access to PL/SQL Developer on your PC. In such a case you should disable the
Store with password option. The History size and Display size preferences control how many
connections will be stored (the oldest one will be removed from the history), and how many will be
displayed on screen. The Sorting option controls how connections are sorted in the selection list.
148
Note that even if you have selected to store passwords in the logon history, you can still prevent this by
holding down the Control key when pressing the Return key or the OK button during logon. This way
you can prevent that passwords of privileged accounts (e.g. SYS or SYSTEM) can be recalled.
You can additionally define a number of fixed accounts in the Fixed Users section, with or without
password. These fixed accounts will always be displayed and will never automatically be removed. You
can additionally define submenu items for these fixed users by adding >menuname. In the example
above, a submenu is created for chicago and detroit:
>chicago
scott/tiger@chicago
sys@chicago as sysdba
>detroit
scott/tiger@detroit
sys@detroit as sysdba
larry@detroit
In this case a submenu was created for a database, but you can create any kind of category you like. For
example Development, Test, Production.
If the Keep fixed users grouped and unsorted option is enabled, the fixed users are displayed in a
separate section from the history, and will not be sorted. If Add fixed users to the history when used
option is enabled, selecting a fixed user during logon will also add it to the history.
In the History section you can see which users were added to the history as a result of a logon in
PL/SQL Developer. To delete a specific item, select it and press the Delete item button next to the list,
or the Delete all items button.
20.9
Oracle Hints
Compiler Hints
You can enable and disable each individual hint, and control other properties of hints when appropriate.
An explanation of each hint and property is displayed below the hint list.
149
Naming Conventions
In this list you can define naming conventions that will be checked when a program unit is compiled, or
when the Show Compiler Hints function is invoked. A hint will be displayed for each element in the
program unit source that does not meet these naming conventions.
For each naming convention you can define the element type (parameter, variable, and so on), the
required prefix for the element type, the possible values for the first and subsequent characters (after the
prefix), the required suffix, and a description for the hint that should be displayed when the naming
convention is not met.
The description should be in the form as displayed in the example above. The actual hint message will
be <Element> <Name> <Description>. For example: Parameter StartDate must start with p_.
If an element must meet one of multiple naming conventions, then you can simply add multiple lines for
the same element type. The descriptions of all lines will be displayed, separated with or. For the
example above the parameter hint message will be:
Parameter 'StartDate' must start with 'p_' or must be 'Self'
150
Autosave username.
This option can be checked to automatically save the username of each PL/SQL Developer session.
When you re-start PL/SQL Developer later, the last username will be default in the logon dialog.
Autosave desktop.
When this option is enabled, all files that were opened when you stop PL/SQL Developer will
automatically be reopened when it is started again. A currently opened Command Window or
Explain Plan Window, which are not associated with a file, will also be restored. Furthermore, the
dimensions of the main window and Object Browser will be restored.
151
Use projects.
The Project main menu item will only be visible if this option is enabled. Disable it if you are not
using projects, so that it does not take up any space in the main menu. For more details about
projects, see chapter 14.
DSA Dialogs.
Whenever you select the Dont show this message again option on a message box, an entry will
be added to the DSA section in your preferences. If you subsequently want to re-enable this
message, press the DSA Dialogs button to edit this section. This will bring up a text editor that
allows you to remove the corresponding line.
152
These preferences control the appearance and behavior of the Object Browser (see chapter 18).
Smooth Refresh.
On some systems this option may slow down the Object Browsers refresh operation (e.g.
changing the Object Browser Filter, logging on as a different user, and so on). If this is the case
you should disable it, though this may lead to some screen flickering when the Object Browser is
refreshed.
Confirm Recompile.
When this preference is enabled, recompiling a program unit in the Object Browser will result in a
153
success or failure message. When it is disabled, you will only see a message when compilation
fails.
The Filters (see chapter 18.2) button and Folders (see chapter 18.3)button will invoke the
corresponding dialog.
Indent
None.
The editor will not indent when pressing the enter key, and will always go to the first character on
the next line.
Automatic.
The editor will automatically indent after pressing the enter key, to the same indent position as the
preceding line.
Smart.
Same as Automatic, except when the previous line starts a new block (e.g. DECLARE, BEGIN,
154
FOR, LOOP, and so on), in which case an extra indent will be inserted. These block words can be
configured through the SmartIndent.txt file in the PL/SQL Developer installation directory.
Step (chars).
The number of characters that the editor will indent when indenting or unindenting a selection.
Backspace unindents.
When enabled, pressing the backspace key will unindent to the previous indent position when
appropriate. When disabled, pressing the backspace key will always delete one character.
Smart tab.
Will cause the editor to tab to a position relative to the previous line.
Tab size.
Determines the number of characters that a tab will use.
Smart fill.
The editor will replace spaces by tabs if possible.
Wrap lines.
Lines that are wider than the window width will be continued on the next line.
Visible margin.
Will display a vertical line at the indicated position. 0 = disabled.
Syntax Highlighting
This group of preferences control the syntax highlighting that is used in the editors. You can enable or
disable syntax highlighting, and define the style and color of keywords, comment, strings, numbers and
symbols (:=, =>, ||, and so on). For keywords you can additionally control if they should be converted to
uppercase, lowercase or capitalized. You can also define a custom syntax highlighting, and define the
words that should be highlighted. Pressing the Custom Keywords button will bring up an editor that
allows you to define these words.
The Keyword Case preferences controls how keywords are formatted when they are typed: Uppercase,
Lowercase or Init Caps.
155
AutoReplace
When enabled, you can define words that are automatically replaced with a replacement text. For
example, if you define the word wo with the replacement text when others then, you can simply type
wo to insert that text.
Pressing the Edit button allows you to edit the file with words and replacement texts. On each line in
this file you can enter a word=replacement text specification. For example:
wo=when others then
rs=rollback to savepoint
You can also reference a template as replacement text. For example:
wh=Loops\While loop.tpl
In this case the While loop template from the Loops template subdirectory will be invoked, allowing you
to use variables and cursor placement for the replacement text.
The Definition file field allows you to specify which file is used for the AutoReplace definitions.
Other
Allow Folding.
When enabled, the PL/SQL Editor of the Program Window will allow you to fold and unfold code
sections, as described in chapter 22.15.
Folding on by default.
Specifies if code folding is on by default when opening or creating a Program Window.
156
the interval between each displayed line number. Use the Font and Size to alter the appearance of
the line numbers.
Highlight parentheses.
When enabled, the editor will highlight the parenthesis pair when the cursor is located at the
opening or closing parenthesis.
Highlight color.
Determines the color of all highlights such as parentheses, variables, and so on.
157
The Fonts preferences control the browser font, editor font and the font used in the various grids like in
the SQL window, the property windows, and so on. By pressing the Select button you can change the
name, style and color of the font. You can also set the background color (Bkg) for each font. For the
Grid and Editor font you can additionally specify whether the font style is included when copying text
to the Windows clipboard. When disabled, it will be copied as plain text.
You can also set the main font for all dialogs.
158
The Code Assistant automatically displays information about database objects as you type their name
(see chapter 22.3). This preference page allows you to define the behavior of this feature.
Automatically activated.
The Code Assistant can automatically be invoked after a certain delay (see below). You can also
choose to manually activate the Code Assistant through a function key.
Delay.
The number of milliseconds that the editor will wait before it displays the Code Assistant List.
Coding Style.
Controls how selected items are inserted into the editor when you select them:
Smart The Code Assistant will look at the described object to determine the style.
Init Caps The first character of each word (separated by an underscore) in capitalized.
Describe users.
Determines if the objects owned by a user are listed when you type a username followed by a
159
period. If this option is enabled, you can additionally define which object types you want to
include in the list.
Describe context.
Determines if the Code Assistant should describe the context of the current user, editor, and
program unit.
Minimum characters.
Determines how many characters of a word need to be typed before the context description can
automatically invoked. Note that you can always invoke the Code Assistant manually, even if the
number of characters have not been typed.
On this page you can define your own key configuration for all functions in PL/SQL Developer. Just
select the function in the list, and press the key combination that you want to use for this function. To
clear a hotkey for a specific function, select it from the list and press the Esc key.
160
Language.
If you have a multi-language version of PL/SQL Developer, you can select a language here. All
captions and messages will subsequently be displayed in that language.
Background Gradient.
Allows you to define the color and gradient of PL/SQL Developers workspace. If you do not
want to use a gradient, but just a single color, set Color 1 and Color 2 to the same value.
161
Connection Indicators.
These options allow you to provide some visual indication when PL/SQL Developer is using
specific connections. You can define a number of connection matches in user@database format
and associate a color with it. This color can subsequently be associated with a left or right aligned
toolbar indicator, an indicator on the window and in the window list, or with the application
background (overriding the background gradient).
A connection match can contain the * and ? wildcard characters. In the example above, the editor
background and right aligned toolbar indicator will be red when connected to the PRODDB
database with any user. It will be yellow when connected as SYS to any database. The first item in
the list will take precedence, so the indicators will be red when connected as SYS to the PRODDB
database. You can add {edition} or {workspace} behind the database name to create an indicator
for specific editions or workspaces.
Display buffering.
The screen will show less flickering when moving or resizing windows, but the display
performance may be slightly slower.
Reset docking.
Resets the docking windows to the default configuration.
Reset toolbars.
Resets the toolbars to the default configuration.
162
On this page you can define the date, time, and number formats that will be used in PL/SQL Developer.
Date format
User defined.
An explicitly defined date format, following the same rules as the Windows regional settings.
Windows format.
The format as defined in the Windows regional settings.
Oracle format.
The format as defined by your Oracle environment (NLS_DATE_FORMAT).
Time format
User defined.
An explicitly defined time format, following the same rules as the Windows regional settings.
Windows format.
The format as defined in the Windows regional settings.
Number format
User defined.
When selected, you can explicitly choose a decimal symbol and digit group symbol.
Windows format.
The format as defined in the Windows regional settings.
Oracle format.
The format as defined by your Oracle environment (NLS_NUMERIC_CHARACTERS).
163
These preferences affect the behavior of the Program Window (see chapter 4).
Background compilation.
When enabled, compilation is performed in a background thread, using a separate session. This
164
way you can continue other work while the compilation occurs. It will lead to an extra database
session for each Program Window though. Note that this preference is only effective if the Session
Mode preference (see chapter 20.1) is set to Multi Session.
Highlight variables.
When the cursor is located on a variable, all occurrences of this variable are highlighted. This
makes it easy to see where a variable is used and what the impact of a change might be. If this
option is disabled, you need to use the Find matches item from the Edit menu.
Error background.
Select the color of the background of the text of a compilation error.
Error text.
Select the color of the text of a compilation error.
165
These preferences affect the behavior of the SQL Window (see chapter 7).
AutoCommit SQL.
This option controls if DML statements executed in a SQL Window are automatically committed.
166
AutoExecute queries.
If this option is enabled, a SQL Window that is created when selecting Query Data or Edit Data
for a Table or View object will immediately be executed. If this option is disabled, you can
modify the generated select statement before executing it.
AutoSelect statement.
If you have more than one SQL statement in the SQL Editor (separated by semi-colons), the SQL
Window will automatically select the statement where the cursor is currently located before
execution. This way you dont have to explicitly select the statement yourself. If you disable this
option, you can still define an Execute current statement SQL Window function key in the
preferences (see chapter 20.15) to quickly execute the current statement.
The column data type, optionality, and comment will be displayed on the status line.
A lookup list will be displayed for columns with a check constraint that checks for specific
values (e.g. col in (value1, value2, ...))
A Lookup list will be displayed for columns with a foreign key constraint to small tables of
less than 1000 rows.
167
Automatically determined The size of the result grid determines how many records are
retrieved.
All records All records are immediately retrieved when the query is executed.
Number layout.
This preference controls how number columns are displayed:
Left aligned Values are displayed left aligned, without any formatting.
Right aligned Values are displayed right aligned, without any formatting.
Formatted Values are displayed right aligned, with a format that corresponds to the
precision and scale of the field.
Formatted with thousand separator Similar to the previous option, but will also include a
thousand separator (e.g. 1,277.65)
Query By Example.
These preferences control the default behavior of the SQL Window during QBE mode (see
chapter 7.3):
Case insensitive Query values of character fields are treated case insensitive.
Automatic Contains Character fields only need to contain the query values.
168
Ignore Time fraction The time fraction of date fields is ignored if the query value does not
contain a time fraction.
These preferences control which columns of the plan table should be displayed in the Plan Window (see
chapter 6.1), and in which order they should appear.
On this preference page you can select the external difference tool for the Compare User Objects tool
(see chapter 21.10). Use the following directives to specify parameters to ignore case or white space:
<IgnoreCase=on|off>
This directive will use the on or off expression if case needs to be ignored or not.
<IgnoreWhiteSpace=on|off>
This directive will use the on or off expression if white space needs to be ignored or not.
For example, for ExamDiff you can use the /i parameter switch to ignore case and /!i to be case
significant, and you can use the /w parameter to ignore white space and /!w to be white space significant.
These switches need to be specified after the filename parameters. Therefore the parameter list for
ExamDiff would look as follows:
169
%1 %2 <IgnoreCase=/i|/!i> <IgnoreWhiteSpace=/w|/!w>
When 2 files need to be compared case sensitive while ignoring white space differences, the resulting
parameter list would be:
c:\temp\file1.sql c:\temp\file2.sql /!i /w
This preference page allows you to define a global set of defaults for the Data Generator tool. These
defaults can be overruled for each data generator definition. For more details about the meaning of these
preferences, see chapter 21.9.
170
These preferences control the values in the Priority, Category and Owner selection lists in the To-Do
Item editor. For the priorities it can be useful to prefix each value with a number, so that the list can be
sorted by priority. See chapter 15 for more details.
On this preference page you can define the maximum number of statements in the statement recall
buffer, and the directory where it should be stored. The directory name can contain environment
variables (e.g. %APDATA%\PLSQL Developer). See chapter 22.4 for more details.
Program files
Defines the starting directory when opening or saving Program files. If you leave this directory
blank, you will always start in the directory you opened or saved a Program file the last time.
Test scripts
Defines the starting directory when opening or saving Test scripts. If you leave this directory
blank, you will always start in the directory you opened or saved a Test script the last time.
171
172
SQL Scripts
Defines the starting directory when opening or saving SQL scripts. If you leave this directory
blank, you will always start in the directory you opened or saved a SQL script the last time.
Report files
Defines the starting directory when opening or saving Report files. If you leave this directory
blank, you will always start in the directory you opened or saved a Report file the last time.
Command files
When open a command file from the menu or by typing @file, this directory will be used by
default. If you leave this directory blank, the working directory will be used.
Macros
This directory will be used to store your macro library. If you leave this directory blank, the
Macro subdirectory in the PL/SQL Directory will be used.
Templates
This directory will be used to store program file templates. If you leave this directory blank, the
Template subdirectory in the PL/SQL Directory will be used.
Plug-Ins
This directory will be used to search for Plug-Ins. If you leave this directory blank, the PlugIn
subdirectory in the PL/SQL Directory will be used.
Projects
Defines the starting directory when opening or saving Projects. If you leave this directory blank,
you will always start in the directory you opened or saved a Project the last time.
Standard queries
Defines the directory where standard queries are stored. If you leave this directory blank, standard
queries will be stored in the application data directory of your profile.
Excel files
Defines the directory where the "Copy to Excel" functions (see chapter 7.2) will create the excel
files.
OFS Locations
Defines the OFS Location Directory File (ofs.ldf). The OFS Manager button allows you to launch
the OFS Manager to view or edit this file. See also chapter 31.1.
173
On this page you can define the default extensions of all file types. When saving or loading such a file,
the default extension is assumed if you do not specify an extension in the file dialog. For each file type
you can additionally specify 'other' extensions, which will be displayed in the file dialogs as well.
Separate multiple extensions with a comma.
By pressing the Register Filetypes button you can associate these default extensions with PL/SQL
Developer. Double-clicking a file with such an extension in the Windows Explorer will automatically
launch PL/SQL Developer. A dialog will appear that allows you to select which extensions you want to
associate with PL/SQL Developer.
174
The Linebreaks option controls how lines are terminated in text files. The can either be terminated in
Windows style by CR/LF character pairs, or in Unix/Linux style by a single LF character. You can
additionally specify that files are in Unix format on specific locations, and in Windows format
otherwise. You can specify multiple directories on separate lines, and select a directory by pressing the
Add location button (...). Note that not only files saved in this directory are formatted in Unix style, but
also all files saved in subdirectories below this directory.
The Encoding option controls if files are always saved in Unicode UTF8 format, always in ANSI format,
or if PL/SQL Developer tries to determine whether a file contains Unicode characters or not. If it
contains Unicode characters, the file is saved in UTF8 format. If all characters are ANSI, the file is
saved in ANSI format. If Save with BOM is disabled, the Unicode Byte Order Mark header is omitted
from the file, so that tools that open this file will need to automatically determine the format.
The Export with smart quotes controls how values are exported in CSV format. When disabled, all
values are enclosed in quotes. When enabled, only those values that require them are enclosed in quotes.
This are values that contain commas or quotes.
The Export to Excel with SQL statement option controls whether or not the SQL statement will be
included on a separate Excel page when a query result is exported in Excel format.
The Excel export format controls whether you will always export in XLS (up to Excel 2003) format or
XLSX (Excel 2007 and higher) format, or that you will be presented with a choice between these 2
formats every time you perform an export.
175
This preference page contains options for backup and recovery of your source files.
Recovery
PL/SQL Developer can store all open files to a temporary location on certain events. In case of a severe
problem (e.g. power failure, software crash, and so on), PL/SQL Developer allows you to recover these
files when it is subsequently started. You can specify the following events:
Save on Execute.
All open files will be stored in a temporary directory before you execute a Program Window, Test
Window, Command Window, SQL Window or Report Window.
176
These preferences allow you to control the HTML and XML output that is generated by the Report
Window and the Export functions:
Charset encoding.
Allows you to define the character set encoding of the HTML or XML document. This should
correspond to the character set of your Oracle environment, so that the data is interpreted correctly.
Heading.
This text will be inserted into the <HEAD> section of an HTML file, or into the standard XML
header of an XML file.
177
General
Print black/white.
All printed output will be black and white. Disabling this option will create output with colors or
gray levels.
Print background.
When enabled, the background color will be printed.
Grid
Print lines.
Determines if the lines of a grid are printed.
Inverted heading.
Determines if the heading of a grid is printed with inverted color.
178
Header
Caption.
When enabled, each page will have the file type and file name printed on the left side of the
header.
Date.
When enabled, each page will have the current date and time printed on the right side of the
header.
Footer
Page numbers.
When enabled, the center of the footer will contain the page number.
Allows you to control if and when PL/SQL Developer checks the Allround Automations web site for
updates and news about PL/SQL Developer. If you disable this option, you can explicitly check for
updates and news by pressing the corresponding option or though the Check Online Updates and Check
Online News items in the Help menu. Set the Proxy Settings if you connect to the internet through a
proxy server.
179
The Personal Preferences are defined for the current Windows user (in this case John). The Default
Preferences can be defined by the system administrator, and provide default preferences for all
Windows users, either at a global level or at a connection level.
Personal preferences
By default all users will have a Default <user> preference set. This is the preference set that you will
access by default. To create an additional preference set for one or more Oracle connections, press the
New button to the right of the preference list. Now you can enter a description and add one or more
connections. For each connection you can use wildcards to match multiple users or databases. In the
example above, a Order admin databases preference set has been defined by John for the dev_oa,
tst_oa, and prd_oa databases. Whenever John connects to one of these 3 databases, this preference set
will be used. If a preference is not defined within this set, the corresponding preference will be used
from the default user preference set.
Default preferences
A system administrator can define global default preferences for all users and all connections, and can
additionally define a default preference set for one or more connections. To do so, switch to the Default
Preferences tab page, and press the New next to the preference list. If you do not enter any Connections,
180
the new preference set will define the default preferences for all users. If you do enter one or more
connections, the preference set will define the default preferences for these connections.
2.
3.
4.
The default preferences are stored in the Default subdirectory. For example:
C:\Program Files\PLSQL Developer\Preferences\Default
If you install PL/SQL Developer on a file server, you must provide read/write access to the Preferences
directory, and read access to the Preferences\Default subdirectory. Alternatively, you can provide the
PREFPATH command-line parameter to specify the directory for the user preferences:
plsqldev.exe prefpath=u:\userdata
If Windows user John uses PL/SQL Developer, his personal preference sets will be stored in
u:\userdata\john. Default preferences are always stored in the Preferences\Default subdirectory within
the PL/SQL Developer installation directory.
To ensure that all users use a similar preference path, you can set this parameter in the params.ini file
(see chapter 33.4).
181
21. Tools
Several tools are available in the Tools menu. These tools are described in this chapter.
21.1
Object Browser
The Object Browser tool is described in detail in chapter 18. In the Tools menu, you can show or hide
the browser by selecting the Object Browser item. You can also define Object Browser Filters from this
menu, which are also described in chapter 18.
21.2
This tool allows you to find database objects based on specific criteria such as the object name, type,
owner, or status, as well as additional full text search criteria for the DDL source of the objects:
You can enter search criteria in the 3 top sections of this form.
Object Criteria
Here you can enter the following criteria:
Browser Filter Limits the objects according to the criteria of the selected filter.
182
Owner The owner of the object. You can use a SQL wildcard characters (e.g. sys%). The
default value is <CURRENT USER>, which will limit the search to objects for the currently
connected user.
Name The name of the object. You can use a SQL wildcard characters (e.g. %common).
Created after/before Limits the search to objects created after and before the specified date.
Use the checkbox to the left of the date field to enable or disable these criteria.
Modified after/before Limits the search to objects modified after and before the specified date.
Use the checkbox to the left of the date field to enable or disable these criteria.
Object Types
Here you can select the range of object types that you want to include in your search.
Search results
After pressing the Search button the search operation is performed in the background and the search
results list will be filled.
If you right-click on the search results you will see the popup menu of an object. The first item in this
popup menu is Locate text, which opens the source in a Program Window, and will immediately take
you to the first occurrence of the search text. You can also invoke the Locate text function by doubleclicking on the item in the search results.
To save the search results you can right-click on them and select an appropriate format from the Export
submenu item in the popup menu.
21.3
With this tool you can easily recompile all invalid objects in the database. When you select it, a dialog
is displayed that shows all invalid objects:
Note that the currently active Browser Filter controls the invalid objects that are included. The bottom
section of the dialog will display any compilation errors that have previously occurred for the currently
selected object.
183
To recompile the objects, press the Compile invalid objects button on the toolbar or Execute on the main
toolbar. The dependencies of the objects will be analyzed to determine in which order compilation
should occur. The icons at the left of the object list will indicate which objects were successfully
compiled. The compilation error section will be updated after compilation is completed.
To refresh the list of invalid objects, press the Refresh object list button on the toolbar. This will update
the list with all currently invalid objects.
In the object list you can right-click on an object to access its popup menu.
21.4
Export Tables
The Export Tables tool allows you to export one or more table definitions and their data into a file, so
that you can import the tables later. After starting the Export Tables tool, you can select the user and the
tables you wish to export, choose an export method (Oracle Export, SQL Inserts, or PL/SQL Developer),
and set various options that apply to the export method:
The export function analyzes the foreign key dependencies that may exist between the tables, and places
the tables in the correct order in the output file.
184
This export method creates a standard SQL script with insert statements and (optionally) DDL
statements to recreate the table definition. The tab page contains the following options:
Drop tables The generated SQL script contains statements to drop the tables before they are
recreated and loaded. The Create tables, Truncate tables, and Delete records options are disabled
in this situation, and have an implicit value.
Create tables The generated SQL script contains statements to create the tables before they are
loaded. This includes constraints, indexes and grants.
Truncate tables The generated SQL script uses truncate table statements to empty the tables
before they are loaded. This option is faster than the Delete tables, but cannot be used if foreign
key constraints exist.
Delete records The generated SQL script uses delete statements to empty the tables before they
are loaded.
Disable triggers The generated SQL script disables all triggers of the tables before they are
loaded, and enables them afterwards. This can improve performance, and can sometimes be
necessary if the triggers contain checks that are not applicable to the import process.
Disable foreign key constraints The generated SQL script disables all foreign keys of the tables
before they are loaded, and enables them afterwards. This can be necessary for self-referencing
foreign keys. Foreign keys between different tables will not lead to conflicts, because the tables
are exported in a correct order. Disabling foreign keys can also improve performance.
Include storage The generated SQL includes the original storage information such as tablespace
names and initial sizes for table creation statements. These may differ across databases, so this
may not always be appropriate.
Include privileges The generated SQL includes the grants of the object privileges to other users
and roles. When the objects are recreated in a different database, these users and roles need to
exist for obvious reasons.
Commit every Controls how many records will be inserted in the generated SQL script before a
commit is executed. If this value is zero, all inserts will be committed at once at the end of the
SQL script. For large export files and small rollback segments it will be necessary to supply an
appropriate value here.
Where clause Only records that match the where clause will be exported. The where clause must
be applicable to all selected tables!
Advantages of this method are the portability of the SQL script, and the possibility to edit the results
with a text editor.
Use the Zip option to automatically zip the output file in order to save disk space. For the example
above the C:\exportdata\demo.sql file will be created, which will then be added to the zip archive
named C:\exportdata\demo.sql.zip. The original demo.sql file will subsequently be deleted.
185
This export method creates a custom, compressed PL/SQL Developer export file with the table
definitions and data. The tab page contains the following options:
Where clause Only records that match the where clause will be exported. The where clause must
be applicable to all selected tables!
Compress file Disabling this option will disable the compression. This can lead to improved
performance if the data cannot be very well compressed (e.g. for long raw or BLOB data that is
already compressed in the database).
Include storage The generated SQL includes the original storage information such as tablespace
names and initial sizes for table creation statements. These may differ across databases, so this
may not always be appropriate.
Include privileges The generated SQL includes the grants of the object privileges to other users
and roles. When the objects are recreated in a different database, these users and roles need to
exist for obvious reasons.
Advantages of this method are the greatly reduced file sizes of the export files, the fact that all options
are deferred to the import phase, and that you can easily select tables during import.
186
21.5
Import Tables
The Import Tables tool allows you to import table definitions and data from a file that was previously
exported with the Export Tables tool described in the previous chapter. Just like with the Export Table
tool, there are 3 methods to import tables, each with its own file format.
This method uses a dump file created by the Oracle export utility, and launches Oracles import utility
to import the data. You can specify various options, each corresponding to a command line option of the
import utility (see the Oracle Server Utilities guide). The Import Executable field allows you to
select a specific version of Oracles import utility. By default the most recent version from the current
Oracle Home will be used.
After the import is finished, a new Log tab page will be visible. This page contains the logging that was
created by the import utility.
187
This method executes the SQL script that was generated by the Export Tables tool. You can choose to
launch SQL*Plus to run the script, or use an internal Command Window. For the SQL*Plus alternative
you can select a specific SQL*Plus executable. By default the version from the current Oracle Home
will be used.
After selecting an import file that was previously exported using the PL/SQL Developer method, you
can select to import one or more files from the list. The following options can be specified:
Drop tables Drop the tables before they are recreated and loaded. The Create tables, Truncate
tables, and Delete records options are disabled in this situation, and have an implicit value.
Create tables Create the table before it is loaded. This includes constraints, indexes and grants.
Truncate tables Truncate the tables before they are loaded. This option is faster than the Delete
tables, but cannot be used if foreign key constraints exist.
188
Delete tables Delete all records in the tables before they are loaded.
Disable triggers Disables all triggers of the tables before they are loaded, and enable them
afterwards. This can improve performance, and can sometimes be necessary if the triggers contain
checks that are not applicable to the import process.
Disable foreign key constraints Disables all foreign keys of the tables before they are loaded,
and enable them afterwards. This can be necessary for self-referencing foreign keys. Foreign keys
between different tables will not lead to conflicts, because the tables are exported in a correct
order. Disabling foreign keys can also improve performance.
Commit every Controls how many records will be inserted before a commit is executed. If this
value is zero, all inserts will be committed at once at the end of the SQL script. For large export
files and small rollback segments it will be necessary to supply an appropriate value here.
21.6
To export the DDL (Data Definition Language) statements of all objects of a user, you can use the
Export User Objects tool. This way you can easily recreate the objects for another user, or in a different
database. After selecting Export User Objects from the Tools menu and selecting a user, all objects of
this user will be presented in a grid:
After selecting an output file, you can press the Export button to export the objects. If no specific
objects are selected in the grid, all objects will be exported. You can select objects by clicking on them,
and using the Control and Shift keys to select multiple objects and ranges of objects.
The output file is a SQL script that is compatible with Oracles SQL*Plus, and with PL/SQL
Developers Command Window. After the export operation you can press the View button to open the
generated file in a Command Window.
The Include Privileges option can be enabled if you want to include the grants of the object privileges to
other users and roles. When the objects are recreated in a different database, these users and roles need
to exist for obvious reasons.
189
Similarly you can enable the Include Storage option to include the storage information such as
tablespace names and initial sizes. These may differ across databases, so this may not always be
appropriate.
The Include Owner option controls whether objects are prefixed with the owner (e.g. SCOTT.EMP
instead of EMP) in the resulting output file(s).
The Single file and File per object and File per object / spec & body in a single file options control
whether a single SQL script is created that contains the DDL for all objects, or if each object should be
exported to a specific file with the object name as filename, and .sql as extension. In case of a package
or type you can optionally choose to get the spec & body in one file. The output file will contain a series
of calls to these object specific files. All files will be written to the directory of the output file.
21.7
Text Importer
With the text importer you can import ASCII files into the database. Most line oriented formats like
comma and tab separated fields are supported. The importer will try to determine the file format
automatically, so most of the time you dont need to define anything, just select the file, select a table,
and thats it.
When you open the text importer and load a text file, you will get something like the following:
The importer loads the first 100 lines from the file. This raw data is shown in the top File Data section.
The middle section allows you to configure the file definition. The bottom Result Preview has a grid
with the data as it would be imported.
190
The toolbar has buttons to select a text file, or paste text from the clipboard. Files can be of virtually
unlimited size, they are not read entirely into memory. The New button will clear everything in the
text importer. The open and save definition buttons allow you to re-use the definition.
If you want to import the text into a new table, press the Create table button. This will invoke the Table
Definition Editor with a column definition that matches the configuration.
The configuration is auto determined as soon as you load a file, but if this is not correct, you can create
of modify this yourself. Set the Fieldcount to the correct number, and select a field from the field list to
define a field definition. In the file data section, the specified field data is highlighted, allowing you to
check if the field definition is correct. You have the following options to configure the text import
definition:
General Fieldcount
The number of fields per record.
191
When you have a correct file definition, you need to select an Oracle table and indicate which text fields
should be imported in which Oracle fields. You can do this on the second tab page:
The top section has some general import parameters. The Fields section allows you to associate text
file fields and Oracle fields. The bottom section is the result preview for your information.
You can set the following general preferences:
Owner / Table
The Oracle table (or view) you want to import the data to. After selecting a table, the importer will
try to determine the field and field types automatically. This will only work if the text file has a
header.
Clear table
When enabled, the all records in the table will be deleted before the import.
Commit every
Indicates after how many records you want to do a commit. If you set this to 0, all data will be
committed at the end of the entire import.
Overwrite Duplicates
A duplicate record will be updated in the database. Duplicates are based on the primary key
value(s) of the table.
Ignore Duplicates
Duplicate records will be ignored.
192
In the field definition you see a list with fields from the text file. For every field you can set the
following:
Field
The Oracle field you want to associate with the text field. You can leave this empty if you dont
want to import this field.
Fieldtype
The basic fieldtype: String, Number or Date.
SQL function
This option allows you to define additional SQL processing. For date fields a to_date function is
added automatically. This is a very powerful option, allowing you to convert the imported data.
Basically, you can enter anything that can be processed by Oracle. You can add a # to indicate the
data. The Create SQL button will fill this field with a to_date function for date fields.
When the definition is complete, you can decide to save it. The toolbar has buttons to save and load
definition files. The text importer will remember which definition file was used for which text file, and
the definition file will be loaded automatically the next time you open the same text file.
You have two import buttons, Import and Import to Script. The first option will start importing the
data into the selected table. The second option will create an SQL script with insert statements.
21.8
ODBC Importer
The ODBC Importer tool allows you to import data from any ODBC data source into an Oracle table:
On the first page of the ODBC Importer you need to select the ODBC data source, and optionally
provide a user name and password for this data source. You can subsequently connect, after which the
table list will be populated with all tables from the data source. Selecting a table will populate the Result
Preview pane. Instead of selecting a table, you can also provide a query by selecting the Import Query
Result option and entering a query text. This can be useful if you want to limit the rows or columns, or
if the results come from more than one table.
193
After entering the source specifications, you can switch to the Data to Oracle tab page to select the
destination table and to specify the column mapping:
In the General section you can select an owner and a table into which the records should be imported.
You can also select if you want to clear the table before the import, select a commit interval (0 =
commit at end) and to ignore duplicate rows or to overwrite them.
In the Fields section you can map fields from the ODBC data source (left) to columns in the Oracle
table (right). For each column you can additionally supply a SQL function. For example, if you want to
convert a string field to uppercase, enter upper(#). The hash sign will be replaced by the field data for
each record, and the resulting expression will be supplied in the insert statement.
After completing the field mapping, you can press the Import button to import the data into the Oracle
table. If you hold down the Ctrl key while pressing this button, an example insert statement will be
displayed so that you can verify the field mapping and SQL functions you specified.
To reuse this import definition later, you can press the Save Definition button on the toolbar. This
definition can be opened later by pressing the Open Definition button.
194
21.9
Data Generator
The data generator allows you to create demo and test data. This can be helpful to test applications and
see how they perform with large amounts of data. You find the Data Generator under the Tools menu.
Basically, the definition consists of one or more tables, the number of records you want to generate, and
the field data definitions. The buttons on the top left allow you to open and save a definition.
Above you see the supplied deptemp demo that creates data for deptdemo and empdemo tables, similar
to the well-known dept and emp tables. You will find the following items on this page:
Number of records The number of records you want to generate. This can be a number, but also
a range like 10..100.
Size The field size (when appropriate). For number fields this will be scale, precision.
Master If this table is the detail of another table, you can set the master. For every generated
master record, the specified number of detail records are generated.
You can use the Add existing table button to add an existing table. You can also drag & drop one
from the Object Bowser.
Data definition
The data definition determines the generated data. If you want to create simple characters, you can enter
character definitions between square brackets: [data]
Data can be a mix of the following pre-defined sets:
195
For example:
[Aaa00] to generate strings like: Gxe21, Liy05, etc.
You can also add literal text between single quotes.
For example:
[AA '-' 1000] to generate strings like: CX-4903, SY-1044, etc.
Space characters in the definition are ignored, unless they are within quotes.
If you want a character repeated a number of times, you can add the number after the character between
brackets (n). You can also add a random number (min..max).
For example:
[Aa(5..15) ' ' Aa(8..20)] for results like: "Masfae Qwwecdsadif"
Literal text in the definition does not have to be enclosed in brackets. In other words, ['hello'] and 'hello'
are equivalent. Text entered without quotes is interpreted as a function.
The are several special functions available:
Random([Min], Max)
Returns random numbers between Min and Max. If only Max is specified, Min is set to 0. For date
fields you can enter dates for Min and Max.
List(select statement)
Like the previous List function, but the items are returned by the SQL select statement. You can
use bind variables to refer by name to previously generated values.
For example: List(select empno from emp where deptno = :deptno) will create a list for all
managers in the department with the currently generated deptno.
SQL(expression)
Returns the given SQL expression. This can include standard SQL values, operators and functions,
as well as user-defined functions. The expression can also be a select statement that returns
exactly one column and one row. You can use bind variables to refer by name to other generated
values.
For example: SQL('Department ' || :deptno)
196
You can change the text results of the previous functions by using the following functions:
Uppercase()
LowerCase()
InitCaps()
For example: InitCaps( List(select ename from emp) )
There are also several predefined data sets available to generate more or less real data. You can use the
following definitions:
City City
State State
Country Country
197
Options
The options tab page allows you to set some preferences specific to the data generator definition. You
can specify a date format (as used for example by the Random function). You can also specify after how
many records you want a commit (set to 0 to commit once when finished). The delay preference is only
useful in some real-time testing where you want data inserted at a specific speed.
The User Definitions section allows you to define or override character sets used in the [data]
definition. The Item is always a single character, and the Value is one or more space separated ranges of
characters like: A..Z a..z 0..9 #200..#220. For example: to define a hexadecimal character set, you could
specify H as the item, and 0..9 A..F as the value.
The Initialization Script section allows you to specify SQL statements that should be executed before
the data is inserted into the database. Typically, this would be a statement to create the tables, or to
truncate the tables, to select a rollback segment, and so on. Multiple statements need to be separated by
semicolons.
General options that will be used by default for all data generators can be defined by pressing the
Preferences button on the left. See chapter 20.23 for more details. These preferences will be overruled if
the corresponding preference in the data generator definition is also set.
Generating Data
There are three buttons available on the bottom left to generate the actual data:
Start a test run This will generate the data and display the results in a grid on the Result tab page.
You can export these results in various formats by right-clicking on the grid.
Create data as SQL Generates the data as a SQL script. This will only work if you dont add data
from files with the file function.
198
After selecting the user that owns the objects on the Selection tab page, you can you can select the
objects you wish to compare. After making this selection, you can press the Target Session button, to
select the user and database that you want to compare. This will enable the Compare button, which you
can press to start the compare operation.
On the Options tab page, you can set the following options:
You can select the Include storage... option to include the storage information such as tablespace names
and initial sizes for new objects. These may differ across databases, so this may not always be
appropriate.
199
The Target schema can be set if the objects in the target session are owned by another user than the
target user that is connected.
The Ignore case in PL/SQL code will ignore case differences that do not affect the meaning of the code.
Case differences in string expressions will not be ignored, because they are significant.
The Ignore white space in PL/SQL code will ignore differences in spaces, tabs and linefeeds that do not
affect the meaning of the code. Differences in string expressions will not be ignored, because they are
significant.
The Ignore comments in PL/SQL code will ignore all differences in comments.
When the compare operation is finished, the dialog will switch to the Differences tab page, which will
show a list of all objects that are different:
This list is sorted in order of dependency. Below the list of different objects of the target user, you see
the SQL that needs to be executed to make these objects equal to the corresponding objects of the
current user. If no object is selected, the SQL of all objects is displayed. If one or more objects are
selected, only the SQL for the selected object(s) is displayed. In the example above, the default values
for the JOB and HIREDATE columns of the EMP table are cleared in the target schema.
The Show Differences button will show a visual line-by-line difference of the old and new source file of
an object. This can be useful to view the changes made in Program Units, or can help you determine
why a specific DDL statement was generated for other object types. The Configure External Difference
Tool button allows you to configure the difference tool should be used. By default the ExamDiff utility
will be used, for which a Pro version is available (See the About item of ExamDiffs Info menu). See
also chapter 20.22.
You can now press the Apply SQL button to execute this SQL in the target session. You can
alternatively save the SQL in a file by pressing the Save SQL button, or you can copy it to the clipboard
by pressing the Copy SQL button.
When objects are compared, the following properties are ignored:
Storage Properties such as the next extent and pct free of tables and indexes are not considered
relevant for comparison.
Constraints with system generated names These constraints will have different names for the 2
users, so they cannot be compared. If a table is new in the target session, these constraints will be
generated though.
200
Table creation properties Properties that would require the recreation of the table are ignored.
Table data To export table data, use the Export Table function (see chapter 21.4).
On the Selection tab page you can select the user that owns the tables, and the table(s) you want to
compare. After making this selection, you can press the Target Session button, to select the user and
database that you want to compare. This will enable the Compare button, which you can press to start
the compare operation, but you can also go to the Options tab page first:
On this page you specify various options for the compare process.
201
Actions You can select the various actions you want to be performed in the target session. If, for
example, you omit the Delete action, only inserts and updates will be performed.
Commit every N records Controls after how many records a commit will occur. If you specify
0, only one commit will occur at the end of the process.
Mode Select Generate script to generate a SQL script with inserts, updates, deletes and commits.
You can save this script later and run it in the Command Window or in SQL*Plus. Select Update
database to immediately apply the changes in the target session.
Target schema If the tables are located in a different schema than the user of the target session,
you can specify this schema here. The target user will need the necessary privileges on the
selected tables in the target schema.
Include owner in SQL This option us only useful in script mode, and will prefix the table
names in the generated SQL with the owner. Doing so will allow you to connect as a different user
later when you run the script, and still apply the changes in the correct schema.
After selecting the appropriate options, you can press the Compare button to start the compare process.
After completion, the Differences will be displayed:
In update mode, this tab page will merely display the total number of inserted, updated, and deleted
records for each table.
In script mode, you can review all differences and save the resulting script by pressing the Save SQL to
file button to the right. Note that you can limit the script to specific tables by making a table selection in
the upper pane. You can also copy the SQL to the clipboard or apply the selected changes in the target
session by pressing the corresponding buttons to the right.
202
Whenever such an event occurs, the name of the pipe or alert and the timestamp is written to the output
page, followed by the information of the event:
Alert: the value of the message parameter of the dbms_alert.signal call is displayed
For alert events you can specify multiple names, separated by colons. For pipe events you can specify
just one pipe name.
203
21.13 Sessions
The Sessions tool displays all sessions in the database instance you are currently connected to:
In the upper half of the window you see information about the sessions, such as the username, the sid
and serial number (which identify the session), the status, and so on. You can sort the session list by
clicking on the header button of a column. For example: to quickly find all active sessions, click on the
header button of the status column.
You can also select a Session Filter from the toolbar to limit the session list to a specific selection of
sessions, or to limit the columns displayed. A filter can also define the order of the session and the
columns.
If you right-click on a session, this will bring up a popup menu with the following items:
Enable SQL Trace Enables SQL Trace for the selected session. This option will be disabled if
your Oracle Server version does not support this feature, or if you do not have privileges on the
dbms_system package.
Disable SQL Trace Disables SQL Trace for the selected session.
Export Export the session list in CSV, TSV, HTML or XML format to a file or to the clipboard.
The Refresh, Kill, Enable SQL Trace and Disable SQL Trace functions are also accessible through the
toolbar at the top of the window. The toolbar additionally includes an Auto refresh button. When
pressed, the session list and session information will periodically be refreshed. You can define the
refresh period by right-clicking on the button.
The bottom half of the window contains several tab pages with information about the selected session.
The information on these tab pages can be refreshed, copied or printed by right-clicking on the list and
204
selecting the corresponding item from the popup menu. For more information about the individual
columns displayed in the lists, see the Oracle Server Reference guide.
You can create, modify or delete the Session Queries for the session list and the session detail tab pages.
To do so, press the Define Session Queries button on the toolbar. This will bring up the following
dialog:
At the top you can switch between the Filters and Detail queries. The filters control what is displayed in
the session list, and the details control what is displayed on the detail tab pages.
At the right side you see four buttons to create a new query, to delete a query, or to move a query up or
down in the list. When you create or modify a query you must supply the following information:
Filters
The Caption shows up in the filter selection list in the toolbar.
The DB Version is the minimum database version for which this filter is applicable.
The Query is the select statement that fetches the session information for the main session list. You can
use this query to:
1.
2.
3.
Details
The Caption shows up on the tabs of the detail tab pages. The position in the list determines the tabposition in the session window.
The DB Version is the minimum database version for which this session detail is applicable.
The Query is the SQL select statement that fetches the session information. This select statement should
usually contain the :sid bind variable, which will contain the sid of the selected session when the query
is executed. You can use any of the columns of the v$session view though, such as
the :username, :sql_address, or :sql_hash_value. If your query leads to an error at run time, it will be
displayed on the corresponding tab page after execution.
205
To concatenate the value(s) of multiple rows of a session detail query, you can use the /* concatenate */
hint in the SQL text. For example:
select sql_text from v$sqltext_with_newlines
where address = hextoraw(:sql_address)
and hash_value = :sql_hash_value
order by piece
/* concatenate */
The sql_text column of all rows returned by this query will be concatenated, and displayed as one value
in the session detail grid.
The four buttons on the right allow you to insert and delete items, as well as to move items up or down
in the list. If you hold down the ctrl key when you press the insert button, the new created item will be
copied from the currently selected one.
206
The Execute button can be used to execute the selected tool. If you hold down ctrl when this button is
selected, a message will popup containing information (with replaced parameters) about what would
have been executed.
The list shows all configured tools and the bottom half shows the configuration of the selected tool. The
configuration is split into three sections:
To explain the external tool configuration we will add a SQL*Plus menu to PL/SQL Developer as an
example.
Meaning
Represents the filename (without path) of the file in the current window
The filename with path
The directory of the file in the current window
The selected browser object (e.g. SCOTT.EMP)
The selected browser object type (e.g. TABLE)
The object owner (SCOTT)
The object name (EMP)
The full connect string of the main PL/SQL Developer connection (e.g. scott/tiger@demo)
The username of the main connection
The password of the main connection
The database of the main connection
The full connect string of the current window connection
The username of the current window connection
The password of the current window connection
The database of the current window connection
207
It turned out that SQL*Plus didnt like a full path with possible spaces as file parameter, thats why #dir
is specified as default directory so only the filename had to be passed to SQL*Plus.
Session tools
For session tools you need to specify a SQL script which can contain multiple SQL statements or
PL/SQL blocks. SQL statements can be separated by semicolons or slashes, PL/SQL blocks need to be
terminated with a slash. This is the same syntax as in SQL*Plus.
Example 1 Germany.sql:
alter session set nls_language = 'german';
alter session set nls_territory = 'germany';
Example 2 SpecialRole.sql:
begin
dbms_session.set_role(role_cmd => 'special_role identified by &Password');
end;
/
Note that you can add substitution variables to the script to make it even more flexible. You will be
prompted for these variable values when the tool is invoked. When the SpecialRole script above is
invoked, you will be prompted for the password.
If you want to use any of the specified parameters in the script, you must use &1, &2 and so on. The
number indicates the order of the parameter on the command-line. You will not be prompted for these
command-line substitution variables.
If you want your tool menu item to be created in a specific main menu you can select one from the Main
menu edit list or you can enter a new menu name if you want to create a new main menu.
If you have entered a Main menu, you can use the Sub menu and Sub-sub menu to indicate the exact
location where you want to create your new menu item.
You can select one of the three location options (Above, Below and At End) to specify where the new
menu item should be placed relative to the specified menu. If you specify a new (sub) menu, you should
always select At End because Below and Above only have a meaning if you refer to an existing (sub)
menu.
208
Example 1:
Main menu
Sub menu
Sub-sub menu
Location
Tools
Oracle tools
At End
This will create an Oracle tools sub menu in the Tools main menu. If you were going to add multiple
Oracle related tools, a specific submenu might be a good idea.
Example 2:
Main menu
Sub menu
Sub-sub menu
Location
Oracle
At End
This will create an Oracle main menu. You should probably only create a new main menu if you are
using the tools regularly and you want them close-by.
If you want to add your tool as first item in the Tools menu you should enter:
Main menu
Sub menu
Sub-sub menu
Location
Tools
Preferences
Above
This will create a menu above the existing Preferences menu item.
Press the Image button to select a Windows bitmap file (*.bmp) for the tool. The size of this image
should preferably be 16 x 16 pixels. Note that PL/SQL Developer will always load the bitmap file from
the original location, so you should not remove or rename this file without also changing the
corresponding external tool. PL/SQL Developer comes with a number of standard bitmap files that you
can choose from. These files are located in the Icons subdirectory in the PL/SQL Developer installation
directory. This is the default directory of the image selector.
The Hint will be displayed as a hint when you hold the mouse cursor over the toolbar button. If you do
not specify a hint, the description of the tool (as displayed in the menu) will be used.
Save Window
When this option is set, the active Window will be saved before the tool is executed. You should
probably do this when the tool gets the file as a parameter and you want to be sure it uses the
current data.
209
Active Connection
If the tool is only useful if PL/SQL Developer is connected (if you pass the connect string as
parameter), you should set the Active Connection setting. This will disable the menu if PL/SQL
Developer is not connected.
Browser Object
Set this option if the tool works on selected objects in the Object Browser
Window Types
If the tool requires a specific window, you can specify these in this section. If one or more are
selected, the menu will only be enabled if the active window type is specified.
For this example the Test Set consists of 3 Test Scripts. For the selected DeptName.tst script the
p_empno variable will get the value 7499 on input, and after execution the result variable value must be
SALES.
210
Running a Test Set will quickly reveal if the tested program units still function correctly and/or with the
required performance:
All failed Test Scripts will have a red indicator and will be placed at the top. In this case the
DeptName(7499) script failed, because the specification required that the result is SALES instead of
the actual Sales value.
This Log pane below the results will show the input values and output values of each variable. If a
selected Test Script generates dbms_output, it will be displayed in the Log pane as well.
Drag & drop a procedure or function from the Object Browser to the Test Manager. A new Test
Window will be opened with a call to this program unit, and variables for all parameters and the
return value. Save the Test Script under a descriptive name, preferably in the same directory as the
Test Set.
2.
211
Press the New button to the right of the Test Script list. The following dialog will appear:
Click Yes to create a new, empty Test Script. You will need to manually program the Test Script
and save it before it can be used in the Test Set.
Click No if you want to add an existing Test Script to the Test Set.
After the Test Script is saved, you can specify the definition in the Test Set:
Test script The filename of the Test Script. This will already by filled in if you have created and
saved a new Test Script. If you want to add an existing Test Script, press the Browse button to the
right of this field.
Description A functional description of the script. If you run a single script multiple times with
different input variable values, you should include this in the description as well so that it can
quickly be recognized in the list.
New Session Use this option to force a new session for the script, so that it becomes
independent of session state changes from previous scripts. By default all scripts use the same
session.
Enabled Use this option to enable or disable the script for the Test Set. Only enabled scripts will
be included in the test run, and disabled scripts will be skipped.
Performance The required performance can be specified as the maximum number of seconds
(fractions allowed). If you leave this field empty, the performance will not be tested.
Variables For each variable in the Test Script, enter the name, input value, and required output
value. The input value will be passed to the Test Script before execution. The required output
value will be tested after execution. If you leave the output value empty, it will not be tested. To
test for null values, enter the word null. Furthermore you can use a like expression (e.g. LIKE
'RES%') or a set expression (e.g. IN (10, 20, 30)) to test output values.
If a variable is marked as Global it will have a global value that will be passed to other Test
Scripts. If a global variable does not have an input value, the global value will be used. After
execution the global value will be updated accordingly.
To test for dbms_output, enter dbms_output for the variable name, and enter the required text
for the output value.
At the lower left you see 2 buttons that allow you to quickly run and check the selected Test Script, or
to open it in a Test Window for editing.
212
indicated with a red indicator, and will be placed at the top of the list. Successful scripts will have a
green indicator, and will be placed at the bottom of the list.
To investigate a failure, right-click on the script and select Debug from the popup menu, or double-click
on the script. A Test Window with the Test Script will be created, and the input variable values will be
set accordingly. Now you can debug the Test Script to determine the cause of the error.
Right-click on the test run results to copy them to the clipboard, to print them, or to export them in
various formats.
This will run the U:\TestSets\DeptEmp.ts test set and will create a log file in D:\Temp\DeptEmp.log. If
you omit the log filename, a log file with the same name as the Test Set will be created.
The log file contains 3 lines for each Test Script:
Test
= <Description of the Test Script>
Result = Success | Failed | Error | Slow | Skipped
Message = <Message of the Test Script run>
This allows you to create a Command File that executes one or more Test Sets. The following script
would run 2 Test Sets and subsequently exit the application:
RunTestSet U:\TestSets\DeptEmp.ts D:\Temp\DeptEmp.log
RunTestSet U:\TestSets\Sales.ts D:\Temp\Sales.log
Exit Application
This script can in turn be called from the PL/SQL Developer command-line. For example:
plsqldev.exe UserID=scott/tiger@chicago CommandFile=U:\TestSets\RunTests.sql
213
22.1
Selection functions
The editor allows you to perform various functions on a selection of text. These functions are available
from the Selection item in the Edit menu, and are only applicable if you have made a text selection. You
can assign a function key to these functions through the Key Configuration preferences.
Indent / Unindent
The number of characters depend on the editor preferences. The Tab and Shift-Tab keys are
always assigned to these 2 functions if a selection exists.
Lowercase / Uppercase
Converts the selected text to lowercase or uppercase, excluding text between single quotes.
Comment / Uncomment
Uses /* and */ to quickly comment a selection.
Sort
The lines of the selection will be sorted in ascending order. If you invoke the sort function again,
the selection will be sorted in descending order.
Color mark
Applies the current marker color to the selection (see also chapter 22.12).
22.2
Column selection
You can select a text column by holding down the Alt key when you make a selection:
214
You can copy, paste, cut, delete, uppercase, lowercase, (un)indent, and (un)comment this selection as
usual. If you use the Apply Syntax Case function, and a keyword crosses the column boundary, it will
not be processed.
22.3
Code Assistant
The code assistant is a very powerful feature that provides help as you type your SQL or PL/SQL code.
When for example you type dbms_alert. and hesitate for a little while, the editor will display a list of
elements in the dbms_alert package:
As you continue to type the name of the dbms_alert procedure, the list will be reduced. If for example
you type an r after dbms_alert., only the register, remove and removeall procedures will still be present
in the list. When you press enter while the Code Assistant is visible, the name of the currently selected
item will be inserted into the source. You can also use the arrow keys to navigate through the Code
Assistant and select the desired item. Press the sort button on the lower left of the Code Assistant to
sort/unsort the items. Pressing the Escape key will remove the Code Assistant.
The Code Assistant will provide assistance for the following object types:
Object type
Package
Function, Procedure
Table, View
Sequence
User
Cursor variable
Record type variable
Table%rowtype variable
Object type
Object type variable
Object type column
Collection variable
:new and :old
Self
@
Elements
Procedures, functions, types, variables, constants and exceptions
Parameters, inserted with named notation (param => )
Columns
nextval and currval
Objects owned by the user
Fields of the select statement of the cursor
Fields of the record type
Columns of the table
Attributes (for default constructor)
Attributes and methods
Attributes and methods
Collection methods (first, next, limit, and so on)
The columns of the table or view of the current trigger
The attributes and methods of the current type
A list of database links
The Code Assistant can also help you type the names of object (tables, packages, and so on), keywords
and PL/SQL identifiers that have meaning within the current context. If, for example, you type pro in a
SQL Editor and hesitate, the keywords procedure and profile will be displayed by the Code Assistant,
along with any database object name that starts with pro. The context depends on the currently
connected user (which determines the available object names), the type of editor (which determines the
available keywords), and the program unit you are editing (which determines the available PL/SQL
215
identifiers). The database object names that are included for this context list are fetched when you first
make a connection to the database. The queries that are executed are defined in the CANames.sql file in
the PL/SQL Developer installation directory or in the %APPDATA%\PLSQL Developer directory. You
can change these queries as needed.
The Code Assistant can be automatically and/or manually invoked, and the delay time before the Code
Assistant automatically becomes active after typing an object name can be defined by a preference.
Furthermore you can define if you want to describe a user, and if so, which object types you want to be
included. The context description and the minimum number of characters that need to be typed before it
can be activated can be configured as well.
For column lists and parameter lists there will be an additional (all) item at the top of the list, which
allows you to add all columns/parameters at once. You can also use the Ctrl and Shift keys to select
multiple items. A preference controls when these items are placed on one line or multiple lines and how
parameters are aligned.
All these preferences are described in chapter 20.14.
22.4
Recalling statements
Whenever you successfully execute a statement in a SQL Window, Command Window, or Report
Window, this statement is stored in the global statement recall buffer. You can recall the most recently
executed statements in the editor by selecting Recall Statement from the Edit menu, or by pressing CtrlE. This will bring up a selection list like this:
The statements are displayed in order of execution, with the most recent one displayed first. In the list
you see the time, the user, and (part of) the statement text. You can now select a statement and doubleclick it (or press Enter) to insert it at the cursor position in the editor from where the list was invoked.
You can select multiple statements by using the Ctrl or Shift keys.
You can sort the list by time, by user or by statement text by pressing the corresponding buttons in the
header of the list.
Note that statements that include passwords are not placed in the global statement recall buffer for
security reasons.
216
If you right-click on the statement list you will see the following popup menu:
All users / Current user Display the statements of the current user or all users.
Find statement Allows you to search for a statement. The find function will start after the
currently selected statement, and will continue at the first statement if it has not found a match.
Can also be invoked by pressing Ctrl-F.
Copy statement(s) Copies the text of the selected statement(s) to the clipboard.
View statement(s) Shows the text of the selected statement(s) in a text editor. This can be useful
when viewing large statements or multiple statements.
Expand selected / all Expands the statements in the list when they consist of more than 1 line.
Collapse selected / all Collapses the list to 1 line per statement after using the Expand function.
Export Allows you to export the statement list to a file in CSV format.
The recall buffer can hold up to 200 statements, which will be stored in the application data directory of
your windows profile. You can change this statement limit and the directory through the preferences
(see chapter 20.25).
22.5
Special Copy
If you are using PL/SQL Developer to write SQL and PL/SQL code that you subsequently want to use
in other tools, such as a 3GL programming language, it may be that you need the code in a slightly
different format. Let us assume that you wrote and tested a SQL statement like this in PL/SQL
Developer:
select deptno, sum(sal) mgr_sal from emp
where job = 'MANAGER'
group by deptno
order by mgr_sal desc
If, for example, you want to use this statement in Borland Delphi, you may need a format like this:
SQL := 'select deptno, sum(sal) mgr_sal from emp' + #13#10 +
'where job = ''MANAGER''' + #13#10 +
'group by deptno' + #13#10 +
'order by mgr_sal desc';
For this purpose you can use the Special Copy function from the Edit menu or from the popup menu
after right clicking on a selection in an editor. This function has a submenu, which shows all special
217
copy formats that are defined. After selecting a format, the converted code is stored on the clipboard, so
that you can paste it in the editor of the corresponding tool.
The special copy formats are defined in the SpecialCopy subdirectory in the PL/SQL Developer
installation directory. You can change the pre-defined copy formats, or add new copy formats. Simply
add a text file with a .copy extension that contains a variable for the first line of the PL/SQL code
(<line_1>), the last line of the PL/SQL code (<line_N>) and a variable for all other lines (<line_*>).
The example for Borland Delphi is as follows:
;PL/SQL Developer SpecialCopy definition for Borland Delphi
;<line_1> for first line
;<line_*> for all other lines
;<line_N> for last line
;
SQL := '<line_1>' + #13#10 +
'<line_*>' + #13#10 +
'<line_n>';
The first line needs to be preceded by the assignment to the SQL variable, and needs to be followed by a
CR/LF pair. The last line does not need the CR/LF pair, but needs to be terminated by a semi-colon. All
other lines merely need to be followed by CR/LF.
You can omit <line_1> and <line_n> if they are the same as <line_*>.
In some languages you need to use escape sequences for special characters. For example, in C++ you
would use \t for a tab character (ASCII code 9). To define these escape sequences, use the #define
keyword:
#define char(9) = \t
#define \ = \\
String("<line_1>\n") +
String("<line_*>\n") +
String("<line_n>");
You can additionally use #define compress to indicate that you want to remove all redundant blank
characters from the result (spaces, tabs, and linefeeds).
Note that the name of the .copy file will be included in the menu, so you should use a descriptive
filename.
22.6
This item from the Edit menu performs the opposite function of the Special Copy menu item. After
copying a piece of source code that includes a SQL statement from a host language like C, Visual Basic
or Pascal, you can paste the actual SQL statement by using this function. If, for example, you have
copied the following Visual Basic code to the clipboard:
SQL = "select empno, sal" & vbCr & _
" from emp" & vbCr & _
" where deptno = 10"
Invoking the Paste from host language function will paste the actual SQL statement:
select empno, sal
from emp
where deptno = 10
218
22.7
Most programmers frequently access reference information on the functions that they are using in their
programs. To find this reference information as quickly as possible, placing the cursor on a keyword in
the source text and pressing F1 will search for this keyword in Oracles online manuals.
You can read chapter 32 for more information about PL/SQL Developers Help system.
22.8
When your program accesses a database object, you very often need to get some information from this
object, or you want to manipulate it. You may want to know its description or its properties. For a table
or view you may want to query or edit the data. For a function or procedure you perhaps want to test a
certain scenario.
If you right-click on an object name in the editor, you will see the same popup-menu that you see when
you right-click on it in the Object Browser. Therefore, all relevant functions for this object are
immediately available from within the editor.
22.9
Explain Plan
To invoke an Explain Plan Window for a SQL statement in an editor, select the text of the statement,
right-click on it, and select the Explain Plan item from the popup menu. If no text is selected, the entire
source will be taken to the Explain Plan Window. If the SQL statement contains PL/SQL variables, you
must alter the statement in the Explain Plan Window as described in chapter 6.1.
22.10 Macros
The editor has a powerful macro function that allows for quick and easy macro recording and playback,
which can be used to automate a specific repetitive task.
A recorded macro can be stored in the Macro Library to be executed later. Macros in the library will
usually be some recurring repetitive task (like swap assignment: a := b; -> b := a;), or may contain code
snippets. For example: why continuously look up how a cursor type must be declared when you can
type it once and record for later use?
To record a macro, press F11 or select the Record item in the Macro menu of the Tools menu. The
toolbar now displays a flashing recorder icon, indicating that you are currently recording a macro. All
keyboard strokes are recorded for playback, which implies that you should not use the mouse during
macro recording. By pressing F11 again, macro recording is ended. Pressing F12 will playback the
macro.
219
To store the currently recorded macro in the Macro Library, select the Library item in the Macro menu.
This will open the Macro Library dialog:
Press the New button to add a new macro with the currently recorded definition. You can enter a
description for the macro and indicate whether it should be included in the Macro menu. This way you
can make some macros easily available, and you can additionally assign a function key to each macro
through the Key Configuration preferences. If the Macros as main menu item option is checked, the
Macros menu is located in the main menu. If it is not checked, it will be located under the Tools menu.
The Description and Image will be displayed in the menu and on the toolbar. Press the Image button to
select a Windows bitmap file (*.bmp) for the macro. The size of this image should preferably be 16 x 16
pixels. Note that PL/SQL Developer will always load the bitmap file from the original location, so you
should not remove or rename this file without also changing the corresponding macro. PL/SQL
Developer comes with a number of standard bitmap files that you can choose from. These files are
located in the Icons subdirectory in the PL/SQL Developer installation directory. This is the default
directory of the image selector.
The Hint will be displayed when you hold the mouse cursor over the toolbar button. If you do not
provide a hint, the description of the macro (as displayed in the library and in the menu) will be used.
Use the Add to menu option to control whether or not the macro will be available from the menu.
On the Keys tab page you can view and change the keyboard actions for the macro.
To execute a stored macro, open the Macro Library and double-click on its name. The selected macro
can now be executed by pressing F12. When you select a macro in the menu, it will immediately be
executed, and it can be re-executed by pressing F12.
22.11 Bookmarks
To mark a location in an editor you can add a bookmark. Simply press Ctrl-Kn (where n is a number
from 0 .. 9) to add a bookmark at the current location. A green bookmark will appear in the gutter, with
the corresponding number. To navigate to this bookmark later, you can press Ctrl-Qn. Alternatively,
you can use the Set bookmark and Go to bookmark submenus from the Edit menu.
220
The Bookmark list item of the Edit menu will bring up an global hierarchical display of all editor
bookmarks:
In this tree view you can see the windows, editors, and lines where a bookmark is located. Clicking on a
bookmark will bring the window and editor to the front, will navigate to that bookmark. You can dock
the bookmark list to make it accessible at all times without blocking any other windows.
To change the marker color, press the arrow next to the button and select a new color. To clear a color
mark, place the cursor within the marked text without making a selection, and press the Color marker
button.
221
The Code Contents keep track of your current location in the source code. As you navigate through the
source code, the selected item will indicate where exactly you are located.
If you move the mouse over an item in the Code Contents, the corresponding source code in the editor
will be highlighted as illustrated above.
Clicking on an item in the Code Contents will immediately navigate to its declaration. Double-clicking
on the item will expand or collapse it. Right clicking on an item will display a popup menu that allows
you to select the corresponding source code in the editor, to cut or copy it to the clipboard, to paste over
it from the clipboard, to convert it to a comment, to expand all child items, or to create a Test Script for
it (if its a public program unit).
The contents can be alphabetically sorted by pressing the Sort contents button at the top of the content
pane. Only the main contents will be sorted: parameters, local variables and so on will not be sorted.
The button will stay down, and pressing it again will revert the contents to their original order.
To close the Code Contents you can click on the Close button at the upper right corner. You can also
right click in the editor and select the Contents item to make it disappear or appear, or select the Code
Contents item in the Tools menu.
By default the Code Contents are visible. To change this default you can close the Code Contents in the
current Program Window and select the Save Layout item in the Window menu.
222
In the example above, the cursor is located at a Select statement within a Code section within an If
statement within a Code section within a Function . If you move the mouse over the items of the
Code Hierarchy, the corresponding source code will be highlighted. Clicking on an item will select the
corresponding source code.
If you right-click on an item (as illustrated above), a popup menu will be displayed that allows you to
select the source code, to cut or copy the source code to the clipboard, to paste the clipboard contents
over the item, to delete the source code, or to convert the source code to or from a comment.
223
To fold a code section, press the minus sign in the left margin of the editor. To unfold it, press the plus
sign in the left margin. You can also right-click in the left margin and select Fold All or Unfold All from
the popup menu. If you move the mouse cursor over a folded line in the editor, the folded section is
temporarily displayed in a separate pane.
You can now navigate, view, and edit both sections simultaneously.
224
If the declaration is located within the same source, PL/SQL Developer will navigate there. After that,
the rest of the program units within the same Program Window will be searched. Then it will search all
other Program Windows that are currently open. Finally, it will try to open a new Program Window, or
SQL Window for the object that contains the declaration and will navigate there.
By default hyperlink navigation will locate a declaration in a package or type specification, if
appropriate. To open the package or type body instead of the specification, you can right-click on a
hyperlink.
If hyperlink navigation opens a new window, it will be updateable. To navigate to read-only windows
instead, disable the corresponding preference (see chapter 20.12).
Bookmarks will be added when you navigate in the Code Contents, use the Find function, click on a
compilation error, go to the top or end of the editor, use hyperlink navigation, open a new window, and
so on.
225
22.19 Refactoring
The refactoring function allows you to quickly reorganize your PL/SQL code. It works on the selected
code, or if no selection is made on the current statement. Right-clicking on a statement or selection
provides the following refactoring functions in the corresponding submenu:
Rename item
Renames the current variable, parameter, constant or program unit. Both the declaration and usage
will be renamed.
Extract procedure
If a program unit has become too large or too complex, you can make a selection and convert it to
a separate procedure. All variables used within and outside of the selection will be converted to
parameters. All variables used only within the selection will be moved from the current program
unit to the new program unit. The selection will be replaced by a call to the new program unit.
If the results of a refactoring action are not satisfactory, you can simply undo it.
After entering a search word, you can press the Search button or press Enter. The search results will be
highlighted in the editor(s), and you can press the Go to next/previous occurrence buttons to navigate
the search results. You can press Esc to move the focus from the search bar to the editor. Press the Hide
occurrences button to clear the highlighted search results in the editors.
226
The Search list button will bring up an hierarchical display of the search results:
In this tree view you can see the files, windows, editors, and lines where the search results are found.
Clicking on a search result will bring the window and editor to the front, will navigate to the search
result, and will select it. You can dock the search list to make it accessible at all times without blocking
any other windows.
On the search bar you can additionally enable options to search all editors or just the current editor, to
search in directories, to search case sensitive, to search for whole words only, and to use regular
expressions.
You can select where to search in files by clicking on the arrow button next to the Search in files button.
The following form will appear:
At the top you can select one or more file locations from the File Browser (see chapter 19), or select one
or more previously saved custom searches. In the bottom section you can explicitly enter file selection
criteria. After closing the form the selected files will be included in the next search, as long as the
Search in files option is selected.
227
You can press the + button to save the current file selection criteria as a custom selection. Press the ^
button to update the current custom selection.
Clicking on a submenu item will perform a web search for the currently selected word(s) in the editor
and will show the results in an external Web Browser or in an internal HTML Window.
In the top section you can see the web searches that have been configured. To the right you have buttons
to create a new web search, to delete a web search, and to move the web searches up and down.
228
In the bottom section you can view and modify the selected web search:
URL The URL that will be opened when the web search is selected. The %s expression will be
replaced by the current editor selection.
Show results Controls whether the results are displayed in an external Web Browser (the default
browser on your system) or in the internal HTML Window.
Reuse Window When enabled, the results will be displayed in a previously opened HTML
Window for this web search. This option is not available when an external Web Browser is used.
229
The toolbar at the top of the editor includes the following buttons:
Cut Place the editor contents on the clipboard in the currently selected format, and subsequently
clear (null) the editor contents.
Copy Place the editor contents on the clipboard in the currently selected format.
Paste Paste the clipboard data into the editor in the currently selected format.
Below the toolbar you can select a tab page for the correct format of the editor contents. Multiple
formats may be applicable for some data. For example, an HTML document can be viewed in HTML
format or in Text format. All data can be viewed in Hex (binary) format.
When making changes to the editor contents in a specific format, you can immediately switch to a
different format to view these changes. For example, when viewing an HTML document you can switch
to Text format to make changes and return to HTML format to view these changes.
230
After pressing the OK button your changes will be propagated to the function from where the Large
Data Editor was invoked.
23.1
The text editor can be used to view or edit any kind of plain text data:
It can also be used to edit XML and HTML text. Switching to the XML or HTML tab page will
immediately show the results of these changes.
23.2
Editing RTF
The RTF editor can be used to view and edit text in Rich Text Format. It allows you to easily change
font type, size, color, style, and alignment:
23.3
231
Editing XML
When viewing XML content, the editor will initially switch to the XML tab page:
Here you can see the structure of the XML document in a tree view, and edit individual elements and
attributes.
Pressing the Parse XML button will parse the XML document, and will report any errors. This requires
that you have Net8 8.1 or later, and that the user has access to the SYS.XMLTYPE type or the
XMLPARSER package.
You can press the Format XML button on the toolbar to apply standard formatting rules on the
document.
If you switch to the plain text format tab page for an XML document, then the appropriate syntax
highlighting will be applied.
232
23.4
Editing HTML
When viewing HTML content, the editor will initially switch to the HTML tab page:
This view is always read-only. You can however switch to the Text tab page to view and edit the data in
plain text format, and switch back to the HTML tab page to view the formatted layout.
23.5
Editing images
The image editor will display images in most popular formats, such as JPG, BMP, GIF, and so on. If the
image is larger than the editor can display, the image will be resized to fit. This does not affect the
contents, it is merely a visual effect. Below the image you will see the image format and the image size
in pixels.
To change an image, you can either press the Open button on the toolbar to load it from a file, or copy
the image from another source to the clipboard and press the Paste button. Note that the image format
will change to BMP when copying/pasting via the clipboard! To ensure that the original format is
preserved you should load it from a file.
23.6
To view or edit the editor contents in hexadecimal format you can switch to the Hex tab page:
233
On the left you see 8 columns with words (16 bits) of hexadecimal data. On the right you see the text
representation of the hexadecimal data. You can edit both the hexadecimal and textual representation.
If you right-click on the hex editor you can select a different column layout.
23.7
For many large objects that are stored in the database it may be necessary to invoke an external viewer
or editor. For example, if a BLOB column contains the contents an Acrobat PDF file (Portable
Document File), it will be necessary to invoke the Acrobat Reader. When invoking the Large Data
Editor for such content, you will initially be taken to the Text or Hex tab page. After that, you can
switch to the External tab page:
234
Here you can define which program should be executed. First you will need to define the file extension.
Before executing the external program, a temporary file with the editor contents will be saved with that
extension. Next you will need to define which program should be executed. After that you can press the
Execute button to view the content in the external program. If you change the file in the external
program and save it, the Large Data Editor will notice this change and will allow you to import these
changes back into the editor.
When viewing column data, the association between the table/column and the external program will be
remembered for the next time you want to view it. If you additionally enable the Execute automatically
next time option, then the Large Data Editor will immediately invoke the external program. To override
this automatic behavior, hold down the Ctrl key when invoking the editor.
Most programs will have registered their file types, and instead of manually defining the extension and
program you can simply select it from a list. First you will need to press the Show registered file types
button. After that you can search for the correct file type and double-click on it. For a PDF file this
would be the Adobe Acrobat File:
If you right-click on the file type list, you can sort it by extension or description (default).
235
24.1
For this example we will assume that we want to create a join statement between the dept and emp table,
and show some columns from both tables:
select e.empno, e.ename, d.deptno, d.dname
from emp e, dept d
order by e.empno
To create a new select statement, place the editor cursor at the text position where you want it to be
inserted, and press the Query Builder button on the toolbar (or select the Query Builder item from the
Tools menu). This will bring up an empty Query Builder Form:
On the left side you see an Object Browser with just the tables and views. On the right you see the
work area, which is empty right now. At the bottom you see 3 panels with the field list (and optionally
the into item list), the where clause and the order by clause. The bottom section contains a tab page that
allows you to switch to the actual SQL text that would be created from the current query definition.
At the top of the window you see a toolbar with a New button to create a new query, an Open button to
open a previously saved query definition from a file, a Save button to save the current query definition
to a file, a Parse button to parse the current query definition, and a Preferences button. The OK button
returns you to the PL/SQL or SQL Editor and inserts the SQL text you have built.
236
To include tables or views in the select statement, drag them from the Object Browser into the work
area. Each time you add a new table, the Table Properties dialog appears:
Here you can enter an alias for the table. For our example we wanted to use e for the emp table:
After adding the Dept table in the same way, you are asked if you want to join the 2 tables using the
columns of the foreign key named EMP_FOREIGN_KEY:
After checking this option, you will see the new join condition in the bottom half of the form.
237
Now the Dept table is added, and the join condition is visualized in the work area:
What we need to do now is include the columns in the field list of the select statement. Just click on the
checkbox next to the column names. The columns will be displayed in the Fields panel:
If you want to create a PL/SQL select .. into statement, you would also need to specify the items for the
Into list next to the fields. The selection list will display the PL/SQL variables that are defined in the
PL/SQL code where you insert the statement. In this case we do not want to create an Into list, so we
can leave these items empty.
238
To create the order by clause, drag the empno column to the Order By panel:
Now you can press the OK button to insert the SQL statement into the editor.
24.2
To modify an existing select statement in your PL/SQL or SQL source code, simply right-click on the
select statement and select the Query Builder item from the popup menu. The complete select statement
will be marked in the editor, and the Query Builder will be displayed. Now you can change the query
definition as described in the previous chapter.
24.3
The following paragraphs describe how you can manipulate the query definition.
239
24.4
By pressing the Preferences button on the toolbar, you can change the behavior of the Query Builder.
The following form will appear:
Most of these preferences affect the layout of the generated select statement:
Keyword case
Determines how the SQL keywords (select, from, into, where, order by) are inserted into the
generated SQL statement.
Item case
Determines how the items (table names, column names) are inserted into the generated SQL
statement.
Keyword alignment
Determines whether the SQL keywords are right or left aligned.
240
Comma separator
Determines whether commas are placed before the next item, or after the current item. This is
primarily of interest if the Single item per line option is enabled.
AND separator
Determines whether the AND operator is placed before the next condition, or after the current
condition in the where clause.
Right margin
Determines the maximum length of each line when the Single item per line preference is disabled.
24.5
If a Query Builder Plug-In is installed, then the standard Query Builder function will invoke the PlugIn. Right-clicking on the Query Builder button allows you to select a query builder from a list of all
installed query builders. The most recently used query builder will be invoked by default when you
subsequently use the Query Builder function again.
241
25.1
To define the PL/SQL Beautifier options, select the corresponding item from the Edit menu. The
following preference dialog will appear:
The Rules file determines the rules that will be followed when beautifying your code. You can leave it
empty to adopt the default rules, which can be defined through a default.br file in the PL/SQL
Developer installation directory. See the next chapter for more information about these rules.
Furthermore you can define when your PL/SQL code will be automatically beautified:
After Creating Whenever a new program file is created through a template, or a DML
statement is dragged and dropped from the Object Browser into a Program Window.
After Loading After a program file is loaded from the file system. This does not affect code that
is opened from the Oracle database.
Before Compiling When you compile a program in the Program Window. This ensures that all
PL/SQL code in the Oracle database conforms to the rules.
242
25.2
If you press the Edit button in the Options dialog, you can view or edit the rules of the selected file:
After making changes to these rules, you can press the Save or Save as button to save these changes.
You can also open another rules file for viewing or editing, and you can revert to the default rules by
pressing the corresponding button. If you save a file under a new name, or open a different file, you
need to select that rules file on the Options dialog to make these rules effective.
On the General tab page you can change the rules that apply to general aspects of your PL/SQL code.
All changes you make are immediately visible in the Preview pane at the bottom of the dialog, and most
options are self-explanatory. The following options need some explanations though:
Indent The number of spaces that will be indented for nested structures such as begin/end,
if/then/else, loops, and so on.
Right margin Whenever code needs to wrap to a following line, the right margin will be used as
a guideline. There may be situations where the right margin is exceeded though, for example when
long strings have been used.
Use tab character When enabled, the resulting code will contain hard tabs (character 9) to
indent the code. When disabled, spaces will be used.
Tab character size The number of characters that a hard tab represents. This is not only useful
when the Use tab character option is enabled, but can also be useful to correctly align comments
that contain hard tabs.
Empty Lines You can define that empty lines should be removed, and that the beautifier will
insert empty lines by its own rules, or that groups of subsequent empty lines should be merged
into one empty line, or that all empty lines are preserved.
243
Item Lists These rules apply to all item lists that do not fall into the categories of the other tab
pages.
Syntax Case Determines how PL/SQL keywords and identifiers are capitalized. The Use
Special Case option allows you to define a number of words that will be included with the
capitalization as specified. If, for example, you include DBMS_Output.Put_Line in this list, this
will be the exact capitalization of that word in your PL/SQL code. You can also use the % or *
wildcards here, so that for example DBA_% will convert the first 3 characters to uppercase for any
word that starts with DBA_.
The other tab pages contain rules that apply to specific aspects of your PL/SQL code. These rules are
again self-explanatory, and are demonstrated in the preview pane.
25.3
If you have not selected any of the beautify events on the Options dialog, you can explicitly beautify
your code by selecting the PL/SQL Beautifier item of the Edit menu, by pressing the corresponding
button on the toolbar, or by using a function key that is assigned to it. By default all code in the current
PL/SQL editor will be beautified. If a critical syntax error is present in the code, it will not be beautified,
and you will receive an error message.
You can alternatively select a complete piece of PL/SQL code (e.g. a local function or procedure, or a
DML statement), and activate the beautifier.
25.4
Suppressing formatting
If you have a piece of PL/SQL code that you want to manually format, and therefore suppress
formatting by the PL/SQL Beautifier, you can use the NoFormat Start and NoFormat End directives.
For example:
...
TimeOut := 1000;
-- NoFormat Start
DBMS_Alert.WaitOne('SHUTDOWN',
Message, Status,
TimeOut);
-- NoFormat End
if Status = 0 then
...
244
26. Templates
Whenever you create a new program unit, its initial contents are based upon a template which contains
pre-defined text and variables. When selecting a template, you will be prompted for the values of these
variables, which are then replaced in the template text.
Templates can also be used to insert pieces of SQL or PL/SQL code into existing source. You could for
example create a template for a cursor-for-loop, and use it whenever you need to program such a control
structure.
Templates are plain text files located in the Template directory and have a .tpl extension. Templates for
all program unit types are pre-defined, as well as templates for common SQL and PL/SQL constructs.
You can modify and create templates for your own specific requirements.
26.1
The Template Window displays the hierarchical structure of the template directory. This makes it easy
to organize your templates. When you start PL/SQL Developer for the first time, the Template Window
will be docked under the Object Browser. This way it is always available and never obstructs the view
of other document windows:
There are a number of templates that are pre-defined, and they are organized in the following template
folders:
Default Templates with the default contents of a SQL Window, Test Window, Command
Window or Explain Plan Window. It also contains the template for a new view object. You
probably wont use these templates directly, but you can maintain them here.
DML Statements Templates for DML statements that you can use in PL/SQL.
Package elements Templates for elements that can be used in package specifications or bodies.
PLSQL Types Templates for all types that can be declared in PL/SQL.
Program Units This is a special folder that contains templates for new program units. Whenever
you create a new program unit, the template from this folder with the same name as the program
unit type will be used.
SQL Functions Templates with all SQL functions, like add_months, substr, and so on. These
templates can be useful if you dont know the exact name or parameter meanings of a specific
function.
Type elements Templates for elements that can be used in type specifications or bodies.
245
By default the Template Window is docked under the Object Browser, but you can turn it into a floating
window by right clicking on it and selecting the Float item from the popup menu. To dock the window
again, follow the same procedure.
You can close the Template Window by selecting the Close item in the popup menu. To make the
Template Window visible again, select the Templates item in the Tools menu.
You can save this layout for the next time you start PL/SQL Developer by using the Save Layout item in
the Window menu, which will save the current situation. This function is described in more detail in
chapter 33.2.
26.2
Using a template
To insert a template into an existing source, you can simply double-click on it. If the template contains
variables that must be specified by the user, an entry form will appear before the text is inserted. If, for
example, you double-click on the Function implementation template, the following entry form will
appear:
246
After filling the form and pressing the OK button, the template text will be inserted into the source, at
the current cursor position:
You can also drag-and-drop a template from the Template Window to a specific position in an editor.
This position will also determine the indentation of the template text. Similarly you can right-click at a
location in the editor, and select a template item from the Templates submenu from the popup menu.
26.3
To modify an existing template, right-click on it and select the Modify item from the popup menu. This
will bring up a text editor with the text of the template. This text contains the complete specification of
the template, including variables, queries, and so on. The format of the template text is described in the
following chapter.
To create a new template, right-click on the folder in which you want to create it, and select the New
Template item from the popup menu. You will first be prompted for the name of the template, after
which the template text editor will appear. You can also create a new folder by selecting the New Folder
item from the popup menu.
Template text
The template specification contains literal text and variables. The literal text will simply be copied into
the source file without any modification. Consider a template called Commit that only contains the
literal text commit;. When this template is double-clicked, the text commit; is inserted into the source at
the cursor position.
User variables
Template variables are codes in the template text that will be replaced with a substitution text. This
substitution text can be an implicit value, like the current date or the username, or can be user-specified.
These user variables will appear in the entry form when the template is invoked. The following example
defines the variables Name and Type for a simplified function template:
create or replace function &Name return &Type is
begin
return(result);
end &Name;
When this template is invoked, the user can specify the values for the Name and Type variables. As you
can see, the Name variable is used twice. The user will be prompted for it only once though, and both
occurrences will be replaced with the same value. More advanced variable properties are available.
247
Templates use the same variable syntax as the SQL Window and Report Window. For a complete
description, see chapter 12.3.
The following is an example of a template for a trigger, using just user variables:
create or replace trigger &"Trigger name"
&<name="Fires"
list="before,after,instead of"
restricted="yes"
default="before"> &<name="Event"
list="insert,update,delete">
on &<name="Table or view"
list="select lower(object_name)
from user_objects
where object_type in ('TABLE', 'VIEW')
order by object_type, object_name">
&<name="Statement level?" checkbox="for each statement,for each row">
declare
-- local variables here
begin
end &"Trigger name";
When this template is used, the user will be prompted for the variable values in the following way:
Note that you can create multiple program units in one template by separating them with a line with just
a slash (/) character. This way you can create a template for a package specification and body in a single
program file.
Implicit variables
Besides the user variables you can additionally use implicit variables. The substitution text for these
variables are not specified by the user, but are defined by the system.
System variables
The following 4 system variables are defined:
$DBUSER The name of the database user that is currently logged on.
248
The first 2 lines of the following example template inserts the Windows user and the current date/time
into a source file:
-- Author : $OSUSER
-- Created : $DATE $TIME
-- Purpose : &Purpose
procedure &Name is
begin
;
end &Name;
Note that system variables do not use ampersands in the template text, but are preceded by a $ sign.
If you want to use the original name of a system variable to appear in the resulting text instead of the
substitution value, you can escape this by placing a second $ sign before the name. For example:
-- $$Date$ $$Revision$
Template icons
The tree view in the Template Window displays an icon for each template. The Template Window first
looks for a bitmap with the same filename as the template. For template Cursor.tpl, it will display a
Cursor.bmp from the same directory, if present. If this bitmap is not present, it will look for a
Cursor.bmp in directories below the current directory. If this bitmap is not found either, it will look for a
default.bmp file in the current directory and the directories below.
The bitmaps for the template icons should have a size of 16x16 pixels with 16 colors.
249
If you click on one of these items the corresponding window will be activated. If you right click on an
item in the Window List, the following popup will be displayed:
From this popup menu you can activate, close, and resize the window to a normal or minimized state.
You can also close a window by shift-clicking on an item in the list.
You can change the connection of a window by selecting it from the Connection submenu.
Furthermore you can rename a window. This can be useful if you just created a new window and want
to provide a meaningful name instead of, for example, SQL Window New.
The Short Text item will switch to shorter descriptions. For example, the description Program Window
- employee.pck will be shortened to P - employee.pck.
The New menu item allows you to create a new Program Window, SQL Window, Test Window,
Command Window, Explain Plan Window, Diagram Window, or a new database object.
To execute a certain window, you can select the Execute menu item.
To close the Window List, use the close button of the docking tool. To make the Window List visible
again select the Winodow List item in the Tools menu. You can save this layout for the next time you
start PL/SQL Developer by using the Save Layout item in the Window menu, which will save the
current situation. This function is described in more detail in chapter 33.2.
250
Object Browser
File Browser
Connection List
Window List
Template List
Bookmark List
Search Bar
Search Results
To-Do Items
Project Items
Tools can be docked at the left, right, upper, and lower side if the work area:
To dock a tool, simply drag it to the corresponding side of the work area. As soon as you come close to
the edge of the work area, a frame will be displayed, indicating the docking position.
If another tool is already docked at this location, you can drag the new tool above, below, to the left, to
the right, or within the other tool. If you drag one tool within the other, they will become available at the
same position on different tab pages (see the Window List and Template List on the lower left in the
screenshot above). Note that you can only dock a tool to the left or right of another tool if the docking
pane is not vertically split.
251
To make a tool float, simply drag it from its docking position to a floating position.
At the upper right of each docking area you see the following 3 buttons from left to right:
This button maximizes or restores the size of the docking area.
This button pins or unpins the docking area. When pinned, the docking area will always be
visible, and tools can always be accessed directly. When unpinned, the docking area will slide off
screen to a vertical tab page when the mouse cursor is not over the area. When you hold the
mouse over a vertical tool tab, the docking area will appear again.
This button closes the current tool of the docking area.
252
29. Toolbars
PL/SQL Developer's Toolbars allows you to quickly access frequently used functions. You can modify
the toolbars to your own liking in the following ways:
You can move the toolbar to a new location on the toolbar area, or drag it out of the toolbar area to
undock it and create a floating toolbar:
253
By selecting the Customize menu item, you can drag & drop commands from the Commands tab page
on the customization form to a toolbar:
When the customization form is open, you can right-click on a button for the following actions and
properties:
Name The name of the button if it includes the Text option (see below).
Image / Text options Controls whether the image and/or text is displayed.
254
Click on the New button to create a new toolbar. This will create an empty toolbar where to which you
can subsequently add buttons. On the same tab page you can rename and delete your own toolbars.
Standard toolbars cannot be modified on this page.
255
30. Authorization
After installing PL/SQL Developer all users can use all PL/SQL Developer functionality, within the
limits of the system privileges and object privileges that are granted to the Oracle user that is connected
to the database. For example, if the Oracle user does not have the create user system privilege, the
PL/SQL Developer user can start the New user function in PL/SQL Developer, but will eventually get
an ORA-01031, insufficient privileges error message from Oracle.
You can explicitly authorize all relevant PL/SQL Developer functionality to specific Oracle users and
roles. In a development database you will allow all developers all functionality, whereas in a production
database you would typically disable all functions for most users that could alter the database or take up
too much resources and would affect performance.
By granting PL/SQL Developer privileges to roles you can customize authorization for specific groups
of people. You can make use of existing roles that implicitly map to a user group (such as DBA and
RESOURCE) or you can create roles specifically for PL/SQL Developer user groups.
30.1
Enabling authorization
The authorization information is stored in the plsqldev_authorization table in the sys schema. As long as
this table does not exist in a database, all users are authorized to use all PL/SQL Developer
functionality. If you are connected to a database where authorization is not yet enabled and select the
Authorization item from the File menu, you will get the following question:
If you select Yes, an empty authorization table is created. Note that you must be connected as a DBA to
create this table. As soon as you create one or more privileges in this table the authorization is enabled,
and only privileged users can use PL/SQL Developer in this database.
By default only the owner of the table (sys) or another DBA can alter the table or update its contents.
All users have select privileges on the table.
256
30.2
Defining authorization
To define the authorization you must be connected as a DBA and start the Authorization function from
the File menu. The following dialog will appear:
At the top you will see all users and roles for which one or more PL/SQL Developer privileges have
been granted. At the bottom you see the actual privileges for the currently selected grantee.
To add a grantee, press the New grantee button to the right of the grantee list. This will bring up a list of
all potential grantees (users and roles). You can select one or more (Ctrl-click or Shift-click) grantees
and press OK to add them. At this point, these new grantees do not have any privileges yet.
To remove a grantee and its privileges, press the Remove grantee button. This will not affect the actual
user or role in the database, but will merely remove its privileges from the authorization table.
To grant privileges, select the grantee from the list and press the Grant privileges button to the right of
the privileges list. A list of all PL/SQL Developer privileges is displayed, where you can select one or
more privileges. There are 3 categories of privileges:
Object privileges Database object type specific privileges (e.g. Drop Table).
Menu privileges Privileges to use PL/SQL Developer menu functions (e.g. Tools > Sessions).
Note: If a user does not have the System.Logon or All privilege, he or she cannot use PL/SQL Developer
on the current database instance.
You can select individual privileges or select from a hierarchical set of privileges. For example:
Objects.Rename All Grant all PL/SQL Developer privileges related to renaming database
objects (rename table, view, sequence and synonym).
257
Note that for database objects, the Oracle user or role must still have the necessary system privilege to
perform the operation. Granting Objects.Drop User still requires the drop user system privilege.
Also note that if a user has the Drop User system privilege, he can still execute the drop user command
from a SQL or PL/SQL script.
30.3
Disabling authorization
To permanently disable authorization, you can drop the sys.plsqldev_authorization table or delete all
records. To temporarily disable authorization, you can either revoke the privileges on the table or
rename it (making it invisible to the PL/SQL Developer users). To enable it again later, you can grant
select privileges again.
258
31.1
OFS Manager
Before anybody can use the OFS from within PL/SQL Developer, you have to use the OFS Manager to
define an OFS Location Directory with one or more OFS Locations. For each location you need to
install the OFS database objects.
This is an empty OFS Location Directory, for which you can add locations, and which you can save in
an OFS Location Directory file (.ldf). This file is used from within PL/SQL Developer to browse the
directory and to connect to locations and browse the files.
259
Schema The schema that holds the OFS database objects (tables, packages, and so on). This user
requires the resource role privilege and the query rewrite system privilege to create its objects.
User name The name of the Oracle user that will be used to access the OFS. If you do not
specify an OFS user name, then the user that accesses the OFS will need to specify a user name
and password, or the OFS will be accessed as the current PL/SQL Developer Oracle user.
Password The password of the Oracle user that will be used to access the OFS. Only useful if the
User name field is entered.
After creating one or more locations, you can save the OFS Location Directory by pressing the Save
button. If you save the file in the PL/SQL Developer directory under the name OFS.ldf, then PL/SQL
Developer will automatically pick-up this directory. Otherwise the PL/SQL Developer user will need to
point to the correct OFS Location Directory file in the preferences.
Next you can install the OFS database objects by pressing the Install database objects button. After
supplying the password of the schema user, the database objects will be created, and the location is
ready for use.
260
31.2
OFS Usage
After creating an OFS Location Directory, installing the locations, and making the directory file
available to PL/SQL Developer, you can use the OFS Save As item from the File menu to save a file
into the OFS. The following dialog will appear:
You first need to open a location, after which you can save the file or create a directory:
To open a file from the OFS, you can use the OFS Open item from the File menu, or use the Reopen
menu. OFS files have the path name OFS:\Location\Path (e.g. OFS:\Chicago\Programs\Employee.bdy).
A previously opened OFS file can be saved by using the standard Save function. You can use the Save
As function to save an OFS file to the standard file system. The OFS Save As function can be used to
save it in the OFS under a different name or in a different directory.
When saving or opening a file, you can select the Keep locked option to lock it. Other users cannot lock
or overwrite a file that is locked by you.
261
Right-clicking on a file in the file selector gives you the option to Cut, Copy, Paste, Delete or Rename
the file. You can also view and change object properties from this popup menu. Properties you can
change include the Read-only status, the Locked status, and the Compressed status. Files can only be
compressed on Oracle10g and later, since it uses the utl_compress package which is only available
since 10g.
262
32.1
MS Help files
Up to Oracle 7.2 the online manuals were provided in MS Help format. These help files can be used to
provide context sensitive help in the editor, either by right clicking on a word, by selecting the SQL help
or PL/SQL help items in the Help menu, or by pressing a function key that you have associated with
these two menu items.
PL/SQL Developer searches the help files in the following two directories:
1. In the directory where PL/SQL Developer is located.
2. In the directory where SQL*Plus is located.
The SQL help file name is assumed to be sqlhelp.hlp, the PL/SQL help file is plshelp.hlp. If these help
files are not available, but you have some other help files you wish to use for SQL or PL/SQL help, you
can place these files in the PL/SQL Developer directory and rename them as mentioned above.
32.2
HTML Manuals
Since Oracle 7.3 the online manuals have been provided in Acrobat Reader and HTML format. You can
configure PL/SQL Developer to make use of the HTML manuals, either by right clicking on a word in
an editor, by selecting the HTML Manuals item in the Help menu, or by pressing F1. Furthermore you
can press the Help button on an error message in case of an Oracle exception, which will automatically
take you to the appropriate paragraph in the Oracle Error Messages manual. Double-clicking on a
compilation error in a Program Window will also display this information.
Note: the online documentation of some Oracle Server versions contains HTML files that are over 1MB
in size. Loading these files can take a very long time, in which case you are advised to use the online
documentation of an Oracle Server version where the chapters are divided into smaller files. Oracle has
reduced file sizes again for the 8.1.5 documentation.
263
Just point to the root directory and press the Build button to create indexes for the keywords in these
manuals, which will be stored in the Books subdirectory of the PL/SQL Developer directory. This
process may take a few minutes.
If you do not have the Oracle HTML documentation available, you can press the Download button. This
will take you to a local html page where you can select the appropriate Oracle Server version and
download a zip file with the HTML documentation. This download requires an Oracle Technology
Network account. If you do not have an OTN account, you can first create one for free.
After this index build is finished, you will be presented with a list of manuals that have been found. You
can now select the books you want to use for context sensitive help. By default this selection will
include the Error Messages, SQL Reference and PL/SQL Reference manuals, which all contain relevant
information during PL/SQL development. The Error Messages manual is required if you want to
automatically have the cause and action available in case of an Oracle exception or compilation error.
The current Oracle7 manual is not properly indexed to allow this feature, the Oracle8 version works
without a problem though.
Press the Apply button to make the selection effective. After this you are taken to the search page, which
is discussed in the following chapter. By pressing the Setup button you can scan a different directory for
HTML manuals.
264
In the Search options pane to the right of the keyword list you can refine the search criterion. Next you
can double click on an item in the topic list at the bottom of the search page to display the
corresponding paragraph in the HTML manual:
The search result page displays an HTML page in which you can navigate through hyperlinks as usual.
The buttons at the top of the page can be used to navigate to the previous or next location that you
visited before, to cancel the page buildup, or to go to the original page after navigating.
265
You can go back to the Search page to search for different keywords or go to the Books page to select
different books. Each search creates a new result tab page, so that you can keep different search results
available. To close a result page, press the close button at the upper right of the tab page. To close all
pages, press the Clear results button on the search page.
By default the HTML window will stay on top of other windows in the PL/SQL Developer IDE, so that
the information stays visible. To temporarily hide the window, you can use the green rollup button at
the upper right of the window.
266
33. Customization
Some aspects of PL/SQL Developer can be customized to meet your personal needs. These aspects are
described in the following paragraphs.
33.1
Preferences
In the Tools menu, there is a Preferences item that allows you to set various preferences for PL/SQL
Developer. These preferences are described in detail in chapter 20.
33.2
Window layout
There are various window layout settings that can be tailored to your needs. Selecting the Save Layout
item in the Window menu saves these settings. The Layout Settings include:
Presence, status (floating or docked) and position of the Window List and Template Window.
Size of the Program Window, Test Window, SQL Window, Explain Plan Window, Command
Window, Report Window, Compile Invalid Objects Window, Find Database Objects Window,
Export User Objects Window, and Compare User Objects Window.
When you save the layout, the size of the last opened window is saved. If a window of a certain type is
not present, the size setting of that window type is left unchanged.
33.3
On-line documentation
Most of Oracle's documentation is provided as on-line documents. Through time, these documents have
had several formats. So far there have been MS Help files, Oracle Book files, Adobe PDF files and
HTML files. In the future, Oracle may choose to use yet another format.
Moreover, you may have some corporate standards and project documents in a word-processor format
that you need to access from time to time.
All of these on-line documents can be integrated into PL/SQL Developer's IDE by including them in the
Documents menu. This way they are available to you by a simple mouse click.
267
To configure on-line documents, select the Configure Documents item in the Tools menu. The
following dialog allows you to define a description of each document, and how to view it:
At the right side you see four buttons, to create a new document, to delete a document, and to move a
document up or down in the menu. When you create or modify a document you must supply the
following information:
The Description shows up in the menu and on the toolbar. To create a shortcut key for the menu item of
a document, prefix the letter in the description with an ampersand. If you want an ampersand in the
description, use two ampersands instead. If you enter just a '-' into the description, it will become a
separator in the menu. This way you can divide the documents into logical groups.
The Executable should be the full path to the program that you want to use to view the document. If the
document is a registered file type (like an MS Help file or HTML file), you can enter the path to the
document here.
The Parameters can be used to pass information to the executable if it is a program. It should at least
include the path to the document, but can also be used to pass options to the program.
When the Documents as main menu item option is checked, the Documents menu is located in the main
menu. If it is not checked, it will be located under the Tools menu.
In the above example the PL/SQL Reference Manual is a PDF file (P:\O9DOC\A89856_01.pdf), which
is a registered file type, so that can just enter the file name in the Executable field. The letter 'P' is used
as a shortcut in the menu. The Documents menu would look like this:
The Hint will be displayed as when you hold the mouse cursor over the toolbar button. If you leave it
empty, the main description of the document (as displayed in the menu) will be used. Press the Image
268
button to select a Windows bitmap file (*.bmp) for the menu and toolbar button. The size of this image
should preferably be 16 x 16 pixels. Note that PL/SQL Developer will always load the bitmap file from
the original location, so you should not remove or rename this file without also changing the
corresponding document. PL/SQL Developer comes with a number of standard bitmap files that you
can choose from. These files are located in the Icons subdirectory in the PL/SQL Developer installation
directory. This is the default directory of the image selector.
33.4
Command-line parameters
The following parameters can be used on the PL/SQL Developer command-line. The default shortcut
does not include any parameters, but merely starts plsqldev.exe from the PL/SQL Developer installation
directory.
A default set of parameters can be defined through the params.ini file in the PL/SQL Developer
installation directory. You can edit the file in a text editor like notepad. The file contains an explanation
for each parameter. If a parameter is defined in params.ini and on the command-line, then the
command-line takes precedence.
userid
Every time you start PL/SQL Developer, it will prompt you for at least the password. To avoid this, you
can supply a userid parameter with the familiar username/password@database format:
plsqldev.exe userid=scott/tiger@chicago
Note that you can also use the following registry key to supply a default logon:
HKEY_CURRENT_USER\Software\Allround Automations\PL/SQL Developer\Logon
Here you can add a Username, Password and Database.
The last method has the advantage that it enables you to be automatically logged on after double
clicking a PL/SQL Developer registered file.
edition
Sets the edition after logging on for Edition Based Redefinition. For example:
plsqldev.exe userid=scott/tiger@chicago edition=R13
workspace
Sets the workspace after logging on for Workspace Management. For example:
plsqldev.exe userid=scott/tiger@chicago workspace=WS12
nologon
The nologon parameter suppresses the logon dialog that is displayed when PL/SQL Developer is started.
This parameter does not require any arguments:
plsqldev.exe nologon
oraclehome
You can specify the name of the Oracle Home on the command line, thereby overriding the Primary
Oracle Home (which is used by default) and the Oracle Home preference:
plsqldev.exe oraclehome=ora817
269
Note that this is the name of the Oracle Home, as specified in the ORACLE_HOME_NAME key in the
registry. This name is also used by the Oracle Home Selector. It is not a registry section name or a
directory name.
dontadjustpath
PL/SQL Developer will not temporarily modify the PATH for Oracle Net initialization:
plsqldev.exe dontadjustpath
nosplash
The nosplash parameter suppresses the splash screen that is displayed when PL/SQL Developer is
started. This parameter does not require any arguments:
plsqldev.exe nosplash
noplugins
Specifying the noplugins parameter will prevent that any Plug-Ins are loaded:
plsqldev.exe noplugins
library
Specify the location of the style library for reports:
plsqldev.exe library=p:\standard.lib
prefpath
Specify the path for the personal preference sets. For example:
plsqldev.exe prefpath=u:\userdata
defaultprefpath
Specify the path for the default preference sets. For example:
plsqldev.exe defaultprefpath=p:\common\plspref
commandfile
Run the specified command file in the Command Window. For example:
plsqldev.exe userid=scott/tiger commandfile=u:\sql scripts\demo_build.sql
This command will first connect to the database and subsequently run demo_build.sql.
viewobject
View the specified database object. It requires that you also specify the userid parameter. For example:
plsqldev.exe userid=scott/tiger@chicago viewobject=emp
270
This command will first connect to the database, and subsequently show the table definition of table
EMP. Note that the object specification can also include the owner (e.g. SCOTT.EMP).
editobject
Edit the specified database object. It requires that you also specify the userid parameter. For example:
plsqldev.exe userid=scott/tiger@chicago editobject=emp
This command will first connect to the database, and subsequently show the table definition of table
EMP. Note that the object specification can also include the owner (e.g. SCOTT.EMP).
registry
To use different sets of IDE settings you can use the registry parameter. For example:
plsqldev.exe registry=home
This command will cause all IDE settings (window sizes & positions, file history, logon history, and so
on) to be loaded from and stored under a home name.
sessionmode
Allows you to define the session mode: single session, dual session, or multi session. Valid values are
SINGLE, DUAL, MULTI or 1, 2, 3. For example:
plsqldev.exe sessionmode=dual
noscwarning
When this parameter is provided, you will not receive a warning when your service contract is about to
expire:
plsqldev.exe noscwarning
hexedit
This parameter will invoke the hex editor of the large data editor for the file specified. For example:
plsqldev.exe hexedit=c:\temp\blob.dat
project
Opens the specified project. For example:
plsqldev.exe project=u:\userdata\projects\deptemp.prj
If you specify * for the project name, the project selector will be displayed during startup:
plsqldev.exe project=*
noconnectionlist
Suppresses the connection list at startup and displays the old style logon dialog instead. For example:
plsqldev.exe noconnectionlist
271
instantclient
Use the instant client from the given directory. For example:
plsqldev.exe instantclient=C:\Oracle\InstantClient11g
tns_admin
Use the given directory as the Oracle network directory (where the tnsnames.ora file resides). For
example:
plsqldev.exe tns_admin=C:\Oracle\Network\Admin
nls_lang
Use the given language, territory and character set. For example:
plsqldev.exe nls_lang=american_america.we8mswin1252
env:[varname]
Set environment variable to the given value. For example:
plsqldev.exe env:nls_date_format=dd-mm-yyyy
NoLoadDesktop
This parameter prevents that windows that were previously opened will be reopened automatically
when PL/SQL Developer starts. It is only applicable when the Autosave Desktop preference is enabled
(see chapter 20.10).
InstanceName
If you are using a multiple monitor setup or a split-screen setup, you can use this parameter to save and
restore form positions for a specific instance. For example:
plsqldev.exe InstanceName=LEFT
33.5
The keywords that are highlighted in SQL, PL/SQL and Command editors can be defined in a keyword
file. The file is named default.kwf and is located in the directory where PL/SQL Developer is installed.
It contains a [PLSQL] section for PL/SQL keywords, a [SQL] section for SQL keywords and a
[COMMAND] section for Command file keywords. You can simply change, add or remove keywords
in the appropriate sections with a text editor like notepad.
33.6
Plug-Ins
You can program your own Plug-Ins to extend the functionality of PL/SQL Developer. Functions in a
Plug-In can be added to the PL/SQL Developer menu, and can perform any kind of action: access the
database, the Object Browser, the current window and editor and so on.
A Plug-In is a DLL that exposes a specific interface to PL/SQL Developer. To create a Plug-In, you can
use any programming language that can create DLLs. When a Plug-In DLL is placed in PL/SQL
272
Developers Plug-In directory, it will automatically be picked up. This makes it very easy to distribute
your Plug-Ins.
You can build Plug-Ins for your own or public use. Some standard Plug-Ins are available on the
Allround Automations web site (http://www.allroundautomations.com/plsqldev.html). Third party PlugIns are available here as well.
Plug-In documentation and examples are available in the PluginDoc subdirectory in the PL/SQL
Developer root directory.