Permalink
Browse files

Version 1.2

The "normal mode" keys are now the same as the command line keys (ym-->Ym, yd -->Yd...).
The commands can be used without calling "Yshow" to display the database meta information.
  • Loading branch information...
1 parent 18bdd7d commit ec024f3f43c4b9aae93289c6f164fa57938da64e Robert Kaltenthaler committed with Oct 18, 2011
Showing with 78 additions and 40 deletions.
  1. +31 −14 doc/orawb.txt
  2. +47 −26 plugin/orawb.vim
View
@@ -1,4 +1,4 @@
-*orawb.txt* For Vim version 7.2. Last change: 2010-09-21
+*orawb.txt* For Vim version 7.2. Last change: 2011-10-13
VIM REFERENCE MANUAL by rkaltenthaler@yahooooo.com
@@ -7,7 +7,6 @@
*orawb* *oracle*
*sqlplus*
This file describes the ORA-Workbench plugin for VIM.
-
1. ORA-Workbench |overview|
2. Installation |install|
3. Starting |starting|
@@ -47,7 +46,7 @@ This plugin has been tested with:
- create the sub-directory "plugin"
- copy the file "orawb.vim" into the "plugin" directory
- create the sub-directory "doc"
- - copy the file "orawb.txt" into the "dic" directory.
+ - copy the file "orawb.txt" into the "doc" directory.
- start vim
- execute the command ":helptags ~/.vim/doc" (linux) or
":helptags ~/vimfiles/doc" (Windows)
@@ -79,7 +78,7 @@ The following commands are used for all windows of the ORA-Workbench:
:Yo[pen] *Yopen*
-Key mapping: yo
+Key mapping: Yo
This commands opens the database object. For objects that contain PL/SQL code,
the source code is displayed in a new buffers. For tables of views, the
@@ -89,25 +88,43 @@ user - so - make sure you know the password.
:Yd[escribe] *Ydescribe*
-Key mapping: yd
+Key mapping: Yd
The command calls the SQLPLUS DESCRIBE function to receive information about
the object under the cursor. For tables or views, the command shows the
columns.
-:Ym[ake] *Ymake*
+:Ym[ake] [parameters...] *Ymake*
+
+Key mapping: Ym
+
+The command has different functions - depending on the window where is
+executes.
+
+When called in a window with "SQL" statements, the statements are send to
+the database with "sqlplus". Any parameters are send to "sqlplus" as "call
+parameters" for the script.
+
+Example:
+If your windows contains:
+ select '&1' || ' ' || '&2' as NAME from dual;
+
+...and you enter the VIM command:
+ :Ymake Kalle Svensson
-Key mapping: ym
+...the ORACLE will respond with:
+ NAME
+ --------------
+ QUIT ROLLBACK
-The command (re) compiles an objects. When calling Ymake from the object tree,
-the selected object is re-compiled using the DDL command:
+When calling Ymake from the object tree, the selected object is re-compiled using the DDL command:
ALTER tt nn COMPILE
where "tt" is the object type (like TRIGGER, FUNCTION...) and "nn" is the name
of the object under the cursor.
:Yi[nvalid] *Yinvalid*
-Key mapping: yi
+Key mapping: Yi
The command searches the current database schema for invalid object. All
invalid objects are listed in a window.
@@ -117,7 +134,7 @@ To close the workbench, use the command Yhide.
:Yw[orksheet] *Yworksheet*
-Key mapping: yw
+Key mapping: Yw
Open a new SQL worksheet.
@@ -197,7 +214,7 @@ The ORA-Workbench shows a window to enter your SQL commands and execute them.
This is the 'Worksheet'. To execute the SQL in the worksheet, use the command
:Ym[ake]
or the key:
- ym
+ Ym
in 'normal' mode. The result is displayed in the log-window of the
ORA-Workbench.
@@ -223,10 +240,10 @@ PROCEDURE,...) that you read back from the database using the command
Within the source window you can use the following commands:
:Ym[ake] - compile the source code. If the PL/SQL contains
- ym errors, you get the error in the 'quickfix' list.
+ Ym errors, you get the error in the 'quickfix' list.
:Yd[escribe] - describe the object under the cursor.
- yd
+ Yd
The worksheet window support the 'omni-complations' function CTRL-X-CTRL-O.
The function is able to complete column name. Example:
View
@@ -1,8 +1,8 @@
" Purpose: Workbench for Oracle Databases
-" Version: 1.1
+" Version: 1.2
" Author: rkaltenthaler@yahoooooo.com
-" Last Modified: $Date: 2010-10-25 11:35:26 +0200 (Mon, 25 Oct 2010) $
-" Id : $Id: orawb.vim 49 2010-10-25 09:35:26Z nikita $
+" Last Modified: $Date: 2011-10-16 16:14:29 +0200 (Sun, 16 Oct 2011) $
+" Id : $Id: orawb.vim 163 2011-10-16 14:14:29Z nikita $
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" Description:
@@ -81,6 +81,7 @@ endif
let loaded_sqlrc=1
+
" Line continuation used here
let s:cpo_save = &cpo
set cpo&vim
@@ -141,7 +142,7 @@ command! YchangeConnection call WBChangeConnection()
" Run the content of the current buffer as SQLPlus commands.
" Send the output to the description window
"
-function WSSqlPlus()
+function WSSqlPlus(...)
if CheckConnection () != 0
return -1
endif
@@ -174,9 +175,21 @@ function WSSqlPlus()
" Paste the text into the buffer
silent execute ":put! z"
+ " Build the command line. The result will look like this:
+ " sqlplus -S kalle/kalle@mydatabase @@ param1 param2 ....
+
+ " Build the parameter part of the command line
+ let params = ""
+ if a:0 > 0
+ let params = " @@"
+ for x in a:000
+ let params = params . " " . x
+ endfor
+ endif
+
" Execute the range and display the result in buffer
" echo a:firstline "," a:lastline
- silent execute '1,$!' . s:sqlcmd . '-S ' . s:connect_string
+ silent execute '1,$!' . s:sqlcmd . '-S ' . s:connect_string . params
normal 1G
" save SQL error message
@@ -468,17 +481,18 @@ endfunction
"
"
function WBKeyMappingGeneral()
- command! Ymake call WSSqlPlus()
+ command! -nargs=* Ymake call WSSqlPlus(<f-args>)
+" command! Ymake call WSSqlPlus()
command! Ydescribe call DescribeObject()
command! Yworksheet call WBInitWorksheet()
" add key mappings
- nmap ys y:call WBShow()<C-M>
- nmap yh y:call WBHide()<C-M>
- nmap yc y:call WBChangeConnection() <C-M>
- nmap yw y:call WBInitWorksheet() <C-M>
- nmap ym y:call WSSqlPlus()<C-M>
- nmap yd y:call DescribeObject()<C-M>
+ nmap Ys Y:call WBShow()<C-M>
+ nmap Yh Y:call WBHide()<C-M>
+ nmap Yc Y:call WBChangeConnection() <C-M>
+ nmap Yw Y:call WBInitWorksheet() <C-M>
+ nmap Ym Y:call WSSqlPlus()<C-M>
+ nmap Yd Y:call DescribeObject()<C-M>
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -497,12 +511,12 @@ function WBKeyMappingCompiler()
command!-buffer Yworksheet call WBInitWorksheet()
" add key mappings
- nmap <buffer> ys y:call WBShow()<C-M>
- nmap <buffer> yh y:call WBHide()<C-M>
- nmap <buffer> yc y:call WBChangeConnection() <C-M>
- nmap <buffer> yw y:call WBInitWorksheet() <C-M>
- nmap <buffer> ym y:call SqlMake()<C-M>
- nmap <buffer> yd y:call DescribeObject()<C-M>
+ nmap <buffer> Ys Y:call WBShow()<C-M>
+ nmap <buffer> Yh Y:call WBHide()<C-M>
+ nmap <buffer> Yc Y:call WBChangeConnection() <C-M>
+ nmap <buffer> Yw Y:call WBInitWorksheet() <C-M>
+ nmap <buffer> Ym Y:call SqlMake()<C-M>
+ nmap <buffer> Yd Y:call DescribeObject()<C-M>
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -579,14 +593,14 @@ function WBShow()
command!-buffer Yupdate call WBLoad()
" load the short-cuts for the tree-buffer
- nmap <buffer> ys y:call WBShow() <C-M>
- nmap <buffer> yh y:call WBHide() <C-M>
- nmap <buffer> yc y:call WBChangeConnection() <C-M>
- nmap <buffer> yd y:call WBDescribeObject() <C-M>
- nmap <buffer> yo y:call WBOpenObject() <C-M>
- nmap <buffer> yu y:call WBLoad() <C-M>
- nmap <buffer> ym y:call WBCompileObject() <C-M>
- nmap <buffer> yi y:call ListInvalidObjects() <C-M>
+ nmap <buffer> Ys Y:call WBShow() <C-M>
+ nmap <buffer> Yh Y:call WBHide() <C-M>
+ nmap <buffer> Yc Y:call WBChangeConnection() <C-M>
+ nmap <buffer> Yd Y:call WBDescribeObject() <C-M>
+ nmap <buffer> Yo Y:call WBOpenObject() <C-M>
+ nmap <buffer> Yu Y:call WBLoad() <C-M>
+ nmap <buffer> Ym Y:call WBCompileObject() <C-M>
+ nmap <buffer> Yi Y:call ListInvalidObjects() <C-M>
nmap <buffer> + zo
nmap <buffer> - zc
endif
@@ -708,6 +722,11 @@ function! WBInitWorksheet()
" Cleanup the buffer
execute "1,$d"
+
+ call append("0","set timing ON")
+ call append("0","--alter session set timed_statistics=true;")
+ call append("0","--set autotrace on explain STATISTICS")
+ call append("0","set linesize 1024")
call append("0","set serveroutput on size 1000000")
call append("0","-- Enter SqlPlus commands here. Press [ym] to execute.")
" execute "w"
@@ -1927,6 +1946,8 @@ augroup SqlPlus
augroup end
+" Load key and command defintions
+call WBKeyMappingGeneral()
" restore 'cpo'
let &cpo = s:cpo_save
unlet s:cpo_save

0 comments on commit ec024f3

Please sign in to comment.