Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 0.0.0.1: Initial upload

  • Loading branch information...
commit 056dd2e6baa81aeaa4ec836dd9b6ad6670b27bd0 0 parents
Lee Teague authored committed
Showing with 65 additions and 0 deletions.
  1. +9 −0 README
  2. +56 −0 doc/oravim.txt
9 README
@@ -0,0 +1,9 @@
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=34
+
+This script allows you to have a SQLWorksheet-type interface to Oracle. Similar to Jeremy Collins&#039 script (vimtip #33), and actually the idea was based on his. It, too, requires that TCL is built in to Vim, and also has a few other requirements: links and a version of SQL*Plus that supports HTML output.
+
+ The usage is quite a bit different, though.
+
+ Start by simply editing a file in vim, and move your cursor to a SQL statement. You can visually select it or not, it doesn&#039t matter as long as there is a blank line before and after. Then, based on these keybindings, hit <C-k> and your statement will be executed, formatted, and popped up in a split window below. To run another statement, move to another one and hit <C-k> again. It will replace the bottom window with the new results.
+
+More detail (and latest versions) at http://oravim.dashf.com/
56 doc/oravim.txt
@@ -0,0 +1,56 @@
+
+** ADD TO ~/.vimrc.tcl: **
+
+set datasource yourdatasource
+set username yourusername
+set password yourpassword
+
+proc executequery { } {
+ global datasource username password
+
+
+ set buf $::vim::current(buffer)
+
+ set sql [join [$buf get $::vim::range(start) $::vim::range(end)] "\n"]
+
+ if { [regexp {"} $sql] } {
+ regsub {^[^"]*"} $sql {} sql
+ regsub {"} $sql {} sql
+ }
+ set sql [string trim $sql]
+ if { ! [string match {*\;} $sql] } { set sql ${sql}\; }
+
+ set execsql "set autotrace on\n"
+ append execsql "set pagesize 10000\n"
+ append execsql "set timing on\n"
+ append execsql "set markup HTML on SPOOL OFF ENTMAP ON PREFORMAT off\n"
+ append execsql $sql
+
+ set result [exec echo "$execsql" | sqlplus -S ${username}/${password}@${datasource} > /tmp/sqlplusoutput.html]
+ exec links -dump /tmp/sqlplusoutput.html > /tmp/sqlplusoutput.sql
+
+ $buf command -quiet "bdelete /tmp/sqlplusoutput.sql"
+ $buf command "set splitbelow"
+ $buf command "sview /tmp/sqlplusoutput.sql"
+ $buf command "set nosplitbelow"
+
+ return
+
+}
+
+
+
+
+
+** ADD TO ~/.vimrc: **
+
+if has("tcl")
+ tcl source if/.vimrc.tcl
+endif
+
+
+vmap <C-k> :tcl executequery<cr>
+map <C-k> vip:tcl executequery<cr>
+imap <C-k> <ESC>vip:tcl executequery<cr>
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.