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: Using macros – Update for version 4.01 ++

[This is a follow up to post SQL-Developer: Using macros]

Has the macro function been dropped?

I got a question from “Bob Thompson“, he asked if the macro function has been removed in SQL Developer version 4.01.
So I tried to use the function on my computer and it still worked.
But then I looked in the preferences (menu “Tools/Preferences”) under “Shortcut Keys”: the macro commands are no loger there!

Dont panik!

The macro feature is still there, what’s missing from version 4.01 on is the ability to add the neccessary shortcut keys via the preferences window.
That’s why it still working on my computer – the update to version 4.01 took over the settings for the shortcut keys.

Workaround

Here is workaround to add the shortcut keys for macro recording and playback manually:

  1. Quit Oracle SQL Developer
    .
  2. Look for the file settings.xml in the following folder:
    %USERPROFILE%\AppData\Roaming\SQL Developer\system4.0.1.14.48\o.ide.12.1.3.2.41.140207.1351\settings.xml
    On some systems it might be in a different place:
    %USERPROFILE%\Application Data\Sql Developer\system4.0.1.14.48\o.ide.12.1.3.2.41.140207.1351\settings.xml
    .
  3. Open the file settings.xml with the text editor of your choice.
  4. Search for the following section in the file:
       oracle/ide/ceditor/keymap/accelerators.xml
          oracle.ide.keyboard.KeyStrokeMap">
             <data>
    
  5. Add the following lines underneath the tag “<data>”:
    <Item class="oracle.javatools.util.Pair">
       <first class="java.lang.String">toggle-macro-recording</first>
       <second class="oracle.ide.keyboard.KeyStrokes">
          <data>
             <Item class="javax.swing.KeyStroke">shift control PERIOD</Item>
          </data>
       </second>
    </Item>
    <Item class="oracle.javatools.util.Pair">
       <first class="java.lang.String">playback-macro</first>
       <second class="oracle.ide.keyboard.KeyStrokes">
          <data>
             <Item class="javax.swing.KeyStroke">control PERIOD</Item>
          </data>
       </second>
    </Item>
    
  6. The final result should look like this:
       oracle/ide/ceditor/keymap/accelerators.xml
          oracle.ide.keyboard.KeyStrokeMap">
             <data>
                <Item class="oracle.javatools.util.Pair">            
                   <first class="java.lang.String">toggle-macro-recording</first>
                   <second class="oracle.ide.keyboard.KeyStrokes">
                      <data>
                         <Item class="javax.swing.KeyStroke">shift control PERIOD</Item>
                      </data>
                   </second>
                </Item>
                <Item class="oracle.javatools.util.Pair">
                   <first class="java.lang.String">playback-macro</first>
                   <second class="oracle.ide.keyboard.KeyStrokes">
                      <data>
                         <Item class="javax.swing.KeyStroke">control PERIOD</Item>
                      </data>
                   </second>
                </Item>
    
  7. Save the file.
    .
  8. Restart Oracle SQL-Developer and use the macro function as describe here:
    SQL-Developer: Using macros

 

Additional informations can be found in these OTN Community posts:

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.