Writing SQL Code
SQL Developer supports three kinds of SQL editors. Statement, script and procedure editors. Each editor window has its own connection, its own transaction and can perform Commit and Rollback commands.
An editor window always uses the current adapter shown in the dropdown list in the tool bar to create its connection. After opening the editor you can use the Open menu item to load the content of a file into the editor. The filename is automatically used for the editor's window title.
There are two ways to save the content of an editor window:
- If the content has been loaded from a file or has already been saved to a file, use the Save command from the File menu.
- Select the Save as command from the File menu if you have created a new content from the scratch or if you want to store the content with a new filename.
Above the input area of each editor window you find a tool bar providing all commands for that editor. You can also use the context menu (right mouse button) to access these commands.
Note: When closing an editor window a rollback is performed automatically on the connection. All uncommitted changes will be discarded.
Each editor supports an undo and a redo function. The undo function can be accessed by pressing Ctrl+Z, press Ctrl+Y to redo text changes.
The Statement Editor is used to execute a single statement. The content of the editor window is sent to the database at once.
The result is visualized as a table in the lower part of the editor window. Each table cell displays a single value from the result set. Because of their size, LOBs (Large OBjects) are displayed partially or as a link. CLOBs (Character LOBs) and BLOBs (Binary LOBs) are shown with their type name and size only. To view the content of such an object select its table cell an click the arrow symbol shown within the cell.
The BLOB viewer displays any kind of binary data in a combined hexadecimal and ASCII view. Use the Save button from the tool bar to save the BLOB to your local computer.
If the current BLOB is a picture, you can view it by changing to the Image tab. The supported formats are JPEG, GIF and PNG. For BLOBs with different format no picture is shown.
The CLOB viewer displays textual content and supports unformatted text and XML. If the current text is XML encoded, the viewer automatically changes to the XML view mode with syntax highlighting. You can format a XML content for easier reading by using the function from the tool bar.
The Script Editor is used to execute scripts consisting of one or more statements. When executing a script the content of the editor window is being parsed and sent to the database as single statements. The result of each statement is shown in the output window.
You can use three different symbols to separate statements in a script:
- Using the keyword GO. Place the keyword at the beginning of a new line.
- The semicolon (;). The terminator must be placed after a statement at the end of a line. Note: The processing of this symbol must be activated in the tool bar. The processing is turned off by default.
- The slash (/). The terminator must be placed at the beginning of a new line. Note: The processing of this symbol must be activated in the tool bar. The processing is turned on by default.
The Stored Program Editor is used to edit stored procedures. To compile a procedure the complete content of the editor window is sent to the database as one block.