vim - dbext seems to think ( is a sql statement terminator -
i have in .sql file in buffer:
create table wh.dbo.customer( id integer not null, cust_name varchar(30) not null, phone_nbr varchar(30) null, primary key(id) );
if in normal mode , cursor on table
sould able hit either <leader>se
or command gvim :dbexecsqlundercursor
, statement should executed dbext should find create
, ;
, execute script in between. following message:
last sql: create table whanalysis.dbo.customer(
if highlight script , choose execute sql (visual selection) plugin menu runs fine.
what going on? setting in _vimrc
?:
set nocompatible source $vimruntime/vimrc_example.vim source $vimruntime/mswin.vim behave mswin set diffexpr=mydiff() " use ctrl-s saving, in insert mode :nnoremap <c-s> :<c-u>update<cr> :vnoremap <c-s> :<c-u>update<cr>gv :cnoremap <c-s> <c-c>:update<cr> :inoremap <c-s> <c-o>:update<cr> " microsoft sql server let g:dbext_default_profile_wh = 'type=sqlsrv:user=dbuser:passwd=dbuserpassword:dsnname=sqloledb.1:srvname=dwdb' set nocp call pathogen#infect() syntax on filetype plugin indent on "mouse , backspace set mouse=a function mydiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let eq = '' if $vimruntime =~ ' ' if &sh =~ '\<cmd' let cmd = '""' . $vimruntime . '\diff"' let eq = '"' else let cmd = substitute($vimruntime, ' ', '" ', '') . '\diff"' endif else let cmd = $vimruntime . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq endfunction nnoremap <leader>p :pyf p:\computer applications\python\ "quick quit command noremap <leader>e :quit<cr> "quits current window " rebind <leader> key let mapleader = "," map <leader>n <esc>:tabprevious<cr> map <leader>m <esc>:tabnext<cr
i spoke plugin maintainer david fishburn - amazed @ time-out took novice me: great guy.
initially suggested
i believe cmd terminator sqlsrv "\ngo\n" not ";".
if want change temporarily try in buffer run: :dbsetoption cmd_terminator=';'
try cmd again.
if works can either override default or change profile override it.
then in answer further related questions:
q1. "\ngo\n" ?
because string enclosed in double quotes, vim treats escaped characters differently. \n - newline go \n - newline
so sql server typical:
create procedure begin end go
which actually:
"end\ngo\n"in other words, "go" has on newline, "go" on line.
q2. add following _vimrc become permanent?:
dbsetoption cmd_terminator=';'
no. :dbsetoption used modify current buffer settings only, not permanent settings.
the best thing can read through :h dbext.txt.
the specific answer question lies in :h dbext-configure-options
5.3 database specific options dbext-configure-options command terminator automatically added command before sent database. command options added command line used execute statement. >
dbext_default_sqlsrv_bin = "osql" dbext_default_sqlsrv_cmd_header = "" dbext_default_sqlsrv_cmd_terminator = "\ngo\n" dbext_default_sqlsrv_cmd_options = '-w 10000 -r -b -n' dbext_default_sqlsrv_extra = ''
so, permanently override buffers in .vimrc add:
let g:dbext_default_sqlsrv_cmd_terminator = ";"
Comments
Post a Comment