SQL-Developer: Create External Tool dialog – Macros (“variables”)

You can use the folloeing commands in “Arguments” and “Run Directory” sections of the “Create External Tool” dialog:

Macro Meaning
${sqldev.conn} DB Connection String
${sqldev.dbuser} DB UserName
${env:var=} Environment Variable
${file.dir} File Directory
${file.ext} File Extension
${file.name} File Name
${file.name.no.ext} File Name Without Extension
${file.path} File Path
${file.url} File URL
${ide.name} IDE Application Name
${ide.classpath} IDE Classpath
${ide.dir} IDE Install Directory
${ide.oracle.dir} IDE Oracle Home Directory
${ide.user.dir} IDE User Directory
${prompt} Prompt
${promptl:=} Prompt with Label
${prop:name=} System Property
Advertisements

SQL-Developer: Copy result grid cells (columns) with headers

We will use the following Select during this post:

SELECT c.owner, c.table_name, c.column_name, c.data_type 
  FROM ALL_TAB_COLUMNS c 
 WHERE table_name = 'ALL_TAB_COLUMNS'
   AND c.column_name like 'DATA%';

Here is the result:

CopyColumns_01

Select certain cells in the result grid

Before we can copy cells in the result grid, we need to select them:

  1. click (left mouse button) inside the first cell of the grid you want to copy
  2. hold down the left mouse button and move your mouse until all cells you want are selected (marked)
  3. release the left mouse button

CopyColumns_Selected

Select all cells in the result grid

If you want to select all cells in the result grid

  1. click somewhere in the result grid (left mouse button)
  2. press CTRL+a to select all cells

Copy cells from the result grid

Select the cells you want to copy and press CTRL+c.
Go to the program of your choice, I will use Excel here, and press CTRL+v:

CopyColumns_Exel

Copy cells with headers from the result grid

Select the cells you want to copy and press CTRL+Shift+c.
Go to the program of your choice, again Excel here, and press CTRL+v:

CopyColumns_Exel_Header

SQL-Developer: Using macros

Are you missing the feature to record and playback a macro in SQL-Developer?
Well, it’s there, just a bit hidden!

[Update: If you use SQL Developer version 4.01 or newer please read this post: Using macros – Update for version 4.01 ++]

Activate the macro functions

  1. Select “Tools/Preferences” from the main menu.
  2. Select “Shortcut Keys” in the list on the left.
  3. Enter “macro” the right search field.
  4. Assign “Ctrl+Period” to “Macro Playback”. Period is the “.” key on your keyboard.
  5. Assign “Ctrl+Shift+Period” to “Macro Toggle Recording”.

Record a macro

To start the recording of the macro, use an editor window of SQL-Developer and press the keys control (ctrl), shift and period (.) together.
The status bar on the bottom shows “Keystroke recording started.”

Any key you will press from now on will be recorded for replay through this macro.

When you are done press the keys control (ctrl), shift and period (.) together again.
The status bar on the bottom shows “Keystroke recording ended.”

There is only one drawback: You can only have one macro at a time. When you record a new macro the previous macro is gone!

Use the macro

Just press the keys control (ctrl) and period (.) together and your macro gets played back.

Example

Adding quotes and commas to a list
Ever wanted the get rid of manually adding quotes and commas to a list of strings?
With a macro it is easy to get from this:

Item 01
Item 02
Item 03

Item 99

to this:

‘Item 01’,
‘Item 02’,
‘Item 03’,

‘Item 99’,

Here is how:

  1. Go to the first line of the list.
  2. Start the recording by pressing the keys control (ctrl), shift and period (.) together.
  3. Press the following keys (pos1) (‘) (end) (‘) (,) and (“arrow down”) one after each other.
  4. End the recording by pressing the keys control (ctrl), shift and period (.) together again.
  5. Play back the macro by pressing the keys control (ctrl) and period (.) together.
  6. Repeat step 5 until the list is done.