11" dbext.vim - Commn Database Utility
22" ---------------------------------------------------------------
3- " Version: 2.10
3+ " Version: 2.11
44" Authors: Peter Bagyinszki <petike1@dpg.hu>
55" David Fishburn <fishburn@ianywhere.com>
6- " Last Modified: Tue Sep 14 2004 5:48:10 PM
6+ " Last Modified: Wed Sep 22 2004 10:35:18 AM
77" Based On: sqlplus.vim (author: Jamis Buck <jgb3@email.byu.edu>)
88" Created: 2002-05-24
99" Homepage: http://vim.sourceforge.net/script.php?script_id=356
1414" - Requires multvals.vim to be installed. Download from:
1515" http://www.vim.org/script.php?script_id=171
1616"
17- " SourceForge: $Revision: 1.30 $
17+ " SourceForge: $Revision: 1.31 $
1818"
1919" Help: :h dbext.txt
2020
@@ -28,7 +28,7 @@ if !exists("loaded_multvals") || loaded_multvals < 304
2828 echomsg " dbext: You need to have multvals version 3.4 or higher"
2929 finish
3030endif
31- let g: loaded_dbext = 210
31+ let g: loaded_dbext = 211
3232
3333" Script variable defaults {{{
3434let s: mv_sep = " ,"
@@ -103,6 +103,7 @@ function! s:DB_buildLists()
103103 let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' custom_title' )
104104 let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' use_tbl_alias' )
105105 let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' delete_temp_file' )
106+ let s: config_params_mv = MvAddElement (s: config_params_mv , s: mv_sep , ' dbext_version' )
106107
107108 " DB server specific params
108109 " See below for 3 additional DB2 items
@@ -528,6 +529,7 @@ function! s:DB_getDefault(name)
528529 elseif a: name == # " replace_title" |return (exists (" g:dbext_default_replace_title" )?g: dbext_default_replace_title .' ' :0 )
529530 elseif a: name == # " use_tbl_alias" |return (exists (" g:dbext_default_use_tbl_alias" )?g: dbext_default_use_tbl_alias .' ' :' d' )
530531 elseif a: name == # " delete_temp_file" |return (exists (" g:dbext_default_delete_temp_file" )?g: dbext_default_delete_temp_file .' ' :' 1' )
532+ elseif a: name == # " dbext_version" |return (g: loaded_dbext )
531533 elseif a: name == # " ASA_bin" |return (exists (" g:dbext_default_ASA_bin" )?g: dbext_default_ASA_bin .' ' :' dbisql' )
532534 elseif a: name == # " ASA_cmd_terminator" |return (exists (" g:dbext_default_ASA_cmd_terminator" )?g: dbext_default_ASA_cmd_terminator .' ' :' ;' )
533535 elseif a: name == # " ASA_cmd_options" |return (exists (" g:dbext_default_ASA_cmd_options" )?g: dbext_default_ASA_cmd_options .' ' :' -nogui' )
@@ -1347,7 +1349,9 @@ function! s:DB_ASA_execSql(str)
13471349 let output = output . s: DB_getWType (" cmd_terminator" )
13481350 endif
13491351
1350- let tempfile = tempname ()
1352+ " Ensure the tempfile has a .sql extension, windows automatically
1353+ " adds an extension, Linux does not.
1354+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
13511355 exe ' redir! > ' . tempfile
13521356 silent echo output
13531357 redir END
@@ -1481,7 +1485,9 @@ function! s:DB_ASE_execSql(str)
14811485 let output = output . s: DB_getWType (" cmd_terminator" )
14821486 endif
14831487
1484- let tempfile = tempname ()
1488+ " Ensure the tempfile has a .sql extension, windows automatically
1489+ " adds an extension, Linux does not.
1490+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
14851491 exe ' redir! > ' . tempfile
14861492 silent echo output
14871493 redir END
@@ -1664,7 +1670,9 @@ function! s:DB_DB2_execSql(str)
16641670 let output = output . s: DB_getWType (" cmd_terminator" )
16651671 endif
16661672
1667- let tempfile = tempname ()
1673+ " Ensure the tempfile has a .sql extension, windows automatically
1674+ " adds an extension, Linux does not.
1675+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
16681676 exe ' redir! > ' . tempfile
16691677 silent echo output
16701678 redir END
@@ -1700,7 +1708,9 @@ function! s:DB_DB2_execSql(str)
17001708 let output = output . s: DB_getWType (" cmd_terminator" )
17011709 endif
17021710
1703- let tempfile = tempname ()
1711+ " Ensure the tempfile has a .sql extension, windows automatically
1712+ " adds an extension, Linux does not.
1713+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
17041714 exe ' redir! > ' . tempfile
17051715 silent echo output
17061716 redir END
@@ -1873,7 +1883,9 @@ function! s:DB_INGRES_execSql(str)
18731883 let output = output . s: DB_getWType (" cmd_terminator" )
18741884 endif
18751885
1876- let tempfile = tempname ()
1886+ " Ensure the tempfile has a .sql extension, windows automatically
1887+ " adds an extension, Linux does not.
1888+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
18771889 exe ' redir! > ' . tempfile
18781890 silent echo output
18791891 redir END
@@ -1956,7 +1968,9 @@ function! s:DB_INTERBASE_execSql(str)
19561968 let output = output . s: DB_getWType (" cmd_terminator" )
19571969 endif
19581970
1959- let tempfile = tempname ()
1971+ " Ensure the tempfile has a .sql extension, windows automatically
1972+ " adds an extension, Linux does not.
1973+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
19601974 exe ' redir! > ' . tempfile
19611975 silent echo output
19621976 redir END
@@ -2041,7 +2055,9 @@ function! s:DB_MYSQL_execSql(str)
20412055 let output = output . s: DB_getWType (" cmd_terminator" )
20422056 endif
20432057
2044- let tempfile = tempname ()
2058+ " Ensure the tempfile has a .sql extension, windows automatically
2059+ " adds an extension, Linux does not.
2060+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
20452061 exe ' redir! > ' . tempfile
20462062 silent echo output
20472063 redir END
@@ -2164,7 +2180,9 @@ function! s:DB_SQLITE_execSql(str)
21642180 let output = output . s: DB_getWType (" cmd_terminator" )
21652181 endif
21662182
2167- let tempfile = tempname ()
2183+ " Ensure the tempfile has a .sql extension, windows automatically
2184+ " adds an extension, Linux does not.
2185+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
21682186 exe ' redir! > ' . tempfile
21692187 silent echo output
21702188 redir END
@@ -2289,7 +2307,9 @@ function! s:DB_ORA_execSql(str)
22892307 let output = output . s: DB_getWType (" cmd_terminator" )
22902308 endif
22912309
2292- let tempfile = tempname ()
2310+ " Ensure the tempfile has a .sql extension, windows automatically
2311+ " adds an extension, Linux does not.
2312+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
22932313 exe ' redir! > ' . tempfile
22942314 silent echo output
22952315 redir END
@@ -2436,7 +2456,9 @@ function! s:DB_PGSQL_execSql(str)
24362456 let output = output . s: DB_getWType (" cmd_terminator" )
24372457 endif
24382458
2439- let tempfile = tempname ()
2459+ " Ensure the tempfile has a .sql extension, windows automatically
2460+ " adds an extension, Linux does not.
2461+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
24402462 exe ' redir! > ' . tempfile
24412463 silent echo output
24422464 redir END
@@ -2584,7 +2606,9 @@ function! s:DB_SQLSRV_execSql(str)
25842606 let output = output . s: DB_getWType (" cmd_terminator" )
25852607 endif
25862608
2587- let tempfile = tempname ()
2609+ " Ensure the tempfile has a .sql extension, windows automatically
2610+ " adds an extension, Linux does not.
2611+ let tempfile = substitute (tempname (), ' \(\..*\)\?$' , ' .sql' , ' ' )
25882612 exe ' redir! > ' . tempfile
25892613 silent echo output
25902614 redir END
@@ -2845,6 +2869,10 @@ function! DB_getListColumn(...)
28452869 " Convert newlines into commas
28462870 " let col_list = substitute( col_list, '\w\>\zs[ '."\<C-J>".']*\ze\w', '\1, ', 'g' )
28472871 let col_list = substitute ( col_list, ' \w\>\zs[^.].\{-}\ze\<\w' , ' , ' , ' g' )
2872+ " Make sure the column list does not end in a newline, makes
2873+ " pasting into a buffer more difficult since you cannot
2874+ " insert it between words
2875+ let col_list = substitute ( col_list, " \\ s*\\ n$" , ' ' , ' ' )
28482876 else
28492877 let col_list = substitute ( col_list, ' ,\s*' , " \n " , ' g' )
28502878 endif
0 commit comments