Commits

boralyl committed 236e4dc

Adding vim-align, pathogen autoload, and dbext.

Comments (0)

Files changed (135)

 let g:netrw_dirhistmax  =10
-let g:netrw_dirhist_cnt =1
+let g:netrw_dirhist_cnt =2
 let g:netrw_dirhist_1='/etc/apache2/mods-enabled'
+let g:netrw_dirhist_2='/home/aaron/.vim'
+" Load pathogen modules
+call pathogen#infect()
+
 " Enable line numbers
 set number
 
 filetype plugin on
 filetype indent on
 
+" Toggle paste on/off.  With it on formatting doesn't get messed up when
+" pasting from an external application
+set pastetoggle=<F2>
+
 " Turn on smart indent
 set smartindent
 set smarttab
 endfunc
 autocmd BufWrite *.py :call DeleteTrailingWS()
 
-""""""""""""""""""""""""""""""
+" Use system clipboard for yank, paste, cut, etc.
+set clipboard+=unnamed
+
+"""""""""""""""""""""""""""""
 " => Command-T
-" """"""""""""""""""""""""""""""
+"""""""""""""""""""""""""""""
 let g:CommandTMaxHeight = 15
 set wildignore+=*.o,*.obj,.git,*.pyc
+
+"""""""""""""""""""""""""""""
+" => Sytastic
+"""""""""""""""""""""""""""""
+let g:syntastic_phpcs_conf = '--standard=/home/aaron/.vim/phpruleset.xml'
+
+"""""""""""""""""""""""""""""
+" => dbext
+"""""""""""""""""""""""""""""
+" MySQL
+let g:dbext_default_profile_mysql_redb01 = 'type=MYSQL:user=agodfrey:passwd=xdYSJx8f^p:host=redb01:dbname=Kap'

autoload/dbext.vim

+" dbext.vim - Commn Database Utility
+" Copyright (C) 2002-10, Peter Bagyinszki, David Fishburn
+" ---------------------------------------------------------------
+" Version:       16.00
+" Maintainer:    David Fishburn <dfishburn dot vim at gmail dot com>
+" Authors:       Peter Bagyinszki <petike1 at dpg dot hu>
+"                David Fishburn <dfishburn dot vim at gmail dot com>
+" Last Modified: 2012 May 22
+" Based On:      sqlplus.vim (author: Jamis Buck)
+" Created:       2002-05-24
+" Homepage:      http://vim.sourceforge.net/script.php?script_id=356
+" Contributors:  Joerg Schoppet 
+"                Hari Krishna Dara 
+"                Ron Aaron
+"                Andi Stern
+"                Sergey Khorev
+"
+" Help:         :h dbext.txt 
+"
+" This program is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 2 of the License, or
+" (at your option) any later version.
+"
+" This program is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this program; if not, write to the Free Software
+" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+if exists('g:loaded_dbext_auto') || &cp
+    finish
+endif
+if v:version < 700
+    echomsg "dbext: Version 4.00 or higher requires Vim7.  Version 3.50 can stil be used with Vim6."
+    finish
+endif
+let g:loaded_dbext_auto = 1600
+
+" Turn on support for line continuations when creating the script
+let s:cpo_save = &cpo
+set cpo&vim
+
+" call confirm("Loaded dbext autoload", "&Ok")
+" Script variable defaults, these are used internal and are never displayed
+" to the end user via the DBGetOption command  {{{
+" let s:dbext_buffers_with_dict_files = ''
+let s:dbext_buffers_with_dict_files = []
+" +shellslash is set on windows so it can be used to decide
+" what type of slash to use
+let s:dbext_tempfile = fnamemodify(tempname(), ":h").
+            \ ((has('win32') && ! exists('+shellslash'))?'\':(has('vms')?'':'/')).
+            \ 'dbext.sql'
+let s:dbext_prev_sql     = ''
+let s:dbext_result_count = 0
+" Store previous buffer information so we can return to it when we 
+" " Store previous buffer information so we can return to it when we 
+" close the Result window
+" close the Result window
+let s:dbext_buffer_last_winnr = -1
+let s:dbext_buffer_last       = -1
+" }}}
+
+" Build internal lists {{{
+function! s:DB_buildLists()
+    " Available DB types - maintainer in ()
+    let s:db_types_mv = []
+    " Sybase Adaptive Server Anywhere (fishburn)
+    call add(s:db_types_mv, 'ASA')
+    " Sybase Adaptive Server Enterprise (fishburn)
+    call add(s:db_types_mv, 'ASE')
+    " DB2 (fishburn)
+    call add(s:db_types_mv, 'DB2')
+    " Ingres (schoppet)
+    call add(s:db_types_mv, 'INGRES')
+    " Interbase (bagyinszki)
+    call add(s:db_types_mv, 'INTERBASE')
+    " MySQL (fishburn)
+    call add(s:db_types_mv, 'MYSQL')
+    " Oracle (fishburn)
+    call add(s:db_types_mv, 'ORA')
+    " PostgreSQL (fishburn)
+    call add(s:db_types_mv, 'PGSQL')
+    " Microsoft Sql Server (fishburn)
+    call add(s:db_types_mv, 'SQLSRV')
+    " SQLite (fishburn)
+    call add(s:db_types_mv, 'SQLITE')
+    " Oracle Rdb (stern)
+    call add(s:db_types_mv, 'RDB')
+    " Sybase SQL Anywhere UltraLite (fishburn)
+    call add(s:db_types_mv, 'ULTRALITE')
+    " Firebird (fishburn)
+    call add(s:db_types_mv, 'FIREBIRD')
+
+    " The following are only available with the
+    " Perl DBI extension plug.
+    " It requires a Perl enabled Vim  (ie echo has('perl')  )
+    " Perl DBI (fishburn)
+    call add(s:db_types_mv, 'DBI')
+    " Perl DBI::ODBC (fishburn)
+    call add(s:db_types_mv, 'ODBC')
+
+    " Integrated Login Supported DB types
+    let s:intlogin_types_mv = []
+    "sybase adaptive server anywhere (fishburn)
+    call add(s:intlogin_types_mv, 'ASA')
+    "microsoft sql server (fishburn)
+    call add(s:intlogin_types_mv, 'SQLSRV')
+
+    " Connection parameters
+    let s:conn_params_mv = []
+    call add(s:conn_params_mv, 'profile')
+    call add(s:conn_params_mv, 'type')
+    call add(s:conn_params_mv, 'integratedlogin')
+    call add(s:conn_params_mv, 'user')
+    call add(s:conn_params_mv, 'passwd')
+    call add(s:conn_params_mv, 'dsnname')
+    call add(s:conn_params_mv, 'srvname')
+    call add(s:conn_params_mv, 'dbname')
+    call add(s:conn_params_mv, 'host')
+    call add(s:conn_params_mv, 'port')
+    call add(s:conn_params_mv, 'extra')
+    call add(s:conn_params_mv, 'bin_path')
+    call add(s:conn_params_mv, 'login_script')
+    call add(s:conn_params_mv, 'driver')
+    call add(s:conn_params_mv, 'conn_parms')
+    call add(s:conn_params_mv, 'driver_parms')
+
+    " Saved connection parameters
+    let s:saved_conn_params_mv = []
+    call add(s:saved_conn_params_mv, 'saved_profile')
+    call add(s:saved_conn_params_mv, 'saved_type')
+    call add(s:saved_conn_params_mv, 'saved_integratedlogin')
+    call add(s:saved_conn_params_mv, 'saved_user')
+    call add(s:saved_conn_params_mv, 'saved_passwd')
+    call add(s:saved_conn_params_mv, 'saved_dsnname')
+    call add(s:saved_conn_params_mv, 'saved_srvname')
+    call add(s:saved_conn_params_mv, 'saved_dbname')
+    call add(s:saved_conn_params_mv, 'saved_host')
+    call add(s:saved_conn_params_mv, 'saved_port')
+    call add(s:saved_conn_params_mv, 'saved_extra')
+    call add(s:saved_conn_params_mv, 'saved_bin_path')
+    call add(s:saved_conn_params_mv, 'saved_login_script')
+    call add(s:saved_conn_params_mv, 'saved_driver')
+    call add(s:saved_conn_params_mv, 'saved_conn_parms')
+    call add(s:saved_conn_params_mv, 'saved_driver_parms')
+
+    " Configuration parameters
+    let s:config_params_mv = []
+    call add(s:config_params_mv, 'use_sep_result_buffer')
+    call add(s:config_params_mv, 'query_statements')
+    call add(s:config_params_mv, 'parse_statements')
+    call add(s:config_params_mv, 'prompt_for_parameters')
+    call add(s:config_params_mv, 'prompting_user')
+    call add(s:config_params_mv, 'always_prompt_for_variables')
+    call add(s:config_params_mv, 'stop_prompt_for_variables')
+    call add(s:config_params_mv, 'use_saved_variables')
+    call add(s:config_params_mv, 'display_cmd_line')
+    call add(s:config_params_mv, 'variable_def')
+    call add(s:config_params_mv, 'variable_def_regex')
+    call add(s:config_params_mv, 'buffer_defaulted')
+    call add(s:config_params_mv, 'dict_show_owner')
+    call add(s:config_params_mv, 'dict_table_file')
+    call add(s:config_params_mv, 'dict_procedure_file')
+    call add(s:config_params_mv, 'dict_view_file')
+    call add(s:config_params_mv, 'replace_title')
+    call add(s:config_params_mv, 'custom_title')
+    call add(s:config_params_mv, 'use_tbl_alias')
+    call add(s:config_params_mv, 'delete_temp_file')
+    call add(s:config_params_mv, 'autoclose')
+    call add(s:config_params_mv, 'autoclose_min_lines')
+    call add(s:config_params_mv, 'variable_remember')
+    call add(s:config_params_mv, 'filetype')
+
+    " Script parameters
+    let s:script_params_mv = []
+    call add(s:script_params_mv, 'use_result_buffer')
+    call add(s:script_params_mv, 'buffer_lines')
+    call add(s:script_params_mv, 'result_bufnr')
+    call add(s:script_params_mv, 'history_bufnr')
+    call add(s:script_params_mv, 'history_file')
+    call add(s:script_params_mv, 'history_size')
+    call add(s:script_params_mv, 'history_max_entry')
+    call add(s:script_params_mv, 'dbext_version')
+    call add(s:script_params_mv, 'inputdialog_cancel_support')
+    call add(s:script_params_mv, 'buffers_with_dict_files')
+    call add(s:script_params_mv, 'use_win32_filenames')
+    call add(s:script_params_mv, 'temp_file')
+    call add(s:script_params_mv, 'window_use_horiz')
+    call add(s:script_params_mv, 'window_use_bottom')
+    call add(s:script_params_mv, 'window_use_right')
+    call add(s:script_params_mv, 'window_width')
+    call add(s:script_params_mv, 'window_increment')
+    call add(s:script_params_mv, 'login_script_dir')
+
+    " DB server specific params
+    " See below for 3 additional DB2 items
+    let s:db_params_mv = []
+    call add(s:db_params_mv, 'bin')
+    call add(s:db_params_mv, 'cmd_header')
+    call add(s:db_params_mv, 'cmd_terminator')
+    call add(s:db_params_mv, 'cmd_options')
+    call add(s:db_params_mv, 'on_error')
+
+    " DBI configuration parameters
+    let s:config_dbi_mv = []
+    call add(s:config_dbi_mv, 'DBI_max_rows')
+    call add(s:config_dbi_mv, 'DBI_disconnect_onerror')
+    call add(s:config_dbi_mv, 'DBI_commit_on_disconnect')
+    call add(s:config_dbi_mv, 'DBI_split_on_pattern')
+    call add(s:config_dbi_mv, 'DBI_read_file_cmd')
+    call add(s:config_dbi_mv, 'DBI_cmd_terminator')
+    call add(s:config_dbi_mv, 'DBI_orientation')
+    call add(s:config_dbi_mv, 'DBI_column_delimiter')
+
+    " DBI connection attributes
+    let s:db_dbi_mv = []
+    call add(s:db_dbi_mv, 'AutoCommit')
+    call add(s:db_dbi_mv, 'PrintError')
+    call add(s:db_dbi_mv, 'PrintWarn')
+    call add(s:db_dbi_mv, 'RaiseError')
+    call add(s:db_dbi_mv, 'Name')
+    call add(s:db_dbi_mv, 'Statement')
+    call add(s:db_dbi_mv, 'RowCacheSize')
+    call add(s:db_dbi_mv, 'Username')
+    call add(s:db_dbi_mv, 'Warn')
+    call add(s:db_dbi_mv, 'Active')
+    call add(s:db_dbi_mv, 'Executed')
+    call add(s:db_dbi_mv, 'Kids')
+    call add(s:db_dbi_mv, 'ActiveKids')
+    call add(s:db_dbi_mv, 'CachedKids')
+    call add(s:db_dbi_mv, 'Type')
+    call add(s:db_dbi_mv, 'ChildHandles')
+    call add(s:db_dbi_mv, 'CompatMode')
+    call add(s:db_dbi_mv, 'InactiveDestroy')
+    call add(s:db_dbi_mv, 'HandleError')
+    call add(s:db_dbi_mv, 'HandleSetError')
+    call add(s:db_dbi_mv, 'ErrCount')
+    call add(s:db_dbi_mv, 'ShowErrorStatement')
+    call add(s:db_dbi_mv, 'TraceLevel')
+    call add(s:db_dbi_mv, 'FetchHashKeyName')
+    call add(s:db_dbi_mv, 'ChopBlanks')
+    call add(s:db_dbi_mv, 'LongReadLen')
+    call add(s:db_dbi_mv, 'LongTruncOk')
+    call add(s:db_dbi_mv, 'TaintIn')
+    call add(s:db_dbi_mv, 'TaintOut')
+    call add(s:db_dbi_mv, 'Taint')
+    call add(s:db_dbi_mv, 'Profile')
+
+    " All parameters
+    let s:all_params_mv = []
+    call extend(s:all_params_mv, s:conn_params_mv)
+    call extend(s:all_params_mv, s:config_params_mv)
+    call extend(s:all_params_mv, s:script_params_mv)
+
+    let loop_count         = 0
+    let s:prompt_type_list = "\n0. None"
+
+    for type_mv in s:db_types_mv
+        let loop_count = loop_count + 1
+        let s:prompt_type_list = s:prompt_type_list . "\n" . loop_count . '. ' . type_mv 
+        for param_mv in s:db_params_mv
+            call add(s:all_params_mv, type_mv.'_'.param_mv)
+        endfor
+    endfor
+
+    " Add 3 additional DB2 special cases
+    call add(s:all_params_mv, 'DB2_use_db2batch')
+    call add(s:all_params_mv, 'DB2_db2cmd_bin')
+    call add(s:all_params_mv, 'DB2_db2cmd_cmd_options')
+
+    " Add 1 additional MySQL special cases
+    call add(s:all_params_mv, 'MYSQL_version')
+
+
+    " Any predefined global connection profiles in the users vimrc
+    let s:conn_profiles_mv    = []
+    let loop_count            = 1
+    let s:prompt_profile_list = "0. None"
+
+
+    " Check if the user has any profiles defined in his vimrc
+    redir => vars
+    silent! let g:
+    redir END
+    let varlist = split(vars, '\n')
+    call map(varlist, 'matchstr(v:val, ''^\S\+'')')
+    call filter(varlist, 'v:val =~ ''^dbext_default_profile_''')
+
+	for item in varlist
+        let prof_name = matchstr(item, 'dbext_default_profile_\zs\(\w\+\)')
+        if strlen(prof_name) > 0
+            call add(s:conn_profiles_mv, prof_name)
+        endif
+	endfor
+    " Sort the list ignoring CaSe
+    let s:conn_profiles_mv = sort(s:conn_profiles_mv,1)
+    " Build the profile prompt string
+	for item in s:conn_profiles_mv
+            let s:prompt_profile_list = s:prompt_profile_list . "\n" .
+                        \  loop_count . '. ' . item
+            let loop_count += 1
+	endfor
+
+    " Check if we are using Cygwin, if so, let the user override
+    " the temporary filename to use backslashes
+    if has('win32unix') && s:DB_get('use_win32_filenames') == 1
+        let l:dbext_tempfile = system('cygpath -w '.s:dbext_tempfile)
+        if v:shell_error 
+            call s:DB_warningMsg('dbext:Failed to convert Cygwin path:'.v:errmsg)
+        else
+            " If executing the Windows path inside a Cygwin shell, you must
+            " double up the backslashes
+            let s:dbext_tempfile = substitute(l:dbext_tempfile, '\\', '\\\\', 'g')
+        endif
+        " let s:dbext_tempfile = substitute(s:dbext_tempfile, '/', '\', 'g')
+    endif
+endfunction 
+"}}}
+
+" Configuration {{{
+"" Execute function, but prompt for parameters if necessary
+function! dbext#DB_execFuncWCheck(name,...)
+    " Record current buffer to return to the correct one
+    let s:dbext_prev_winnr = winnr()
+    let s:dbext_prev_bufnr = bufnr('%')
+ 
+    let use_defaults = 1
+    if s:DB_get("buffer_defaulted") != 1
+        let rc = s:DB_resetBufferParameters(use_defaults)
+        if rc == -1
+            call s:DB_warningMsg( "dbext:A valid database type must be chosen" )
+            return -1
+        endif
+        if a:name == 'promptForParameters'
+            " Handle the special case where no parameters were defaulted
+            " but the process of resettting them has defaulted them.
+            call s:DB_warningMsg( "dbext:Connection parameters have been defaulted" )
+        endif
+    endif
+
+    if exists('*s:DB_'.a:name) == 0
+        call s:DB_warningMsg( "dbext:Function DB_".a:name." does not exist" )
+        return "-1"
+    endif
+
+    echon 'dbext: Executing SQL at '.strftime("%H:%M")
+
+    " Could not figure out how to do this with an unlimited #
+    " of variables, so I limited this to 4.  Currently we only use
+    " 1 parameter in the code (May 2004), so that should be fine.
+    if a:0 == 0
+        return s:DB_{a:name}()
+    elseif a:0 == 1
+        return s:DB_{a:name}(a:1)
+    elseif a:0 == 2
+        return s:DB_{a:name}(a:1, a:2)
+    elseif a:0 == 3
+        return s:DB_{a:name}(a:1, a:2, a:3)
+    else
+        return s:DB_{a:name}(a:1, a:2, a:3, a:4)
+    endif
+endfunction
+
+"" Execute function, but prompt for parameters if necessary
+function! dbext#DB_execFuncTypeWCheck(name,...)
+
+    " Record current buffer to return to the correct one
+    let s:dbext_prev_winnr = winnr()
+    let s:dbext_prev_bufnr = bufnr('%')
+ 
+    let use_defaults = 1
+    if s:DB_get("buffer_defaulted") != 1
+        let rc = s:DB_resetBufferParameters(use_defaults)
+        if rc == -1
+            call s:DB_warningMsg( "dbext:A valid database type must be chosen" )
+            return rc
+        endif
+    endif
+
+    if !exists("*s:DB_".b:dbext_type."_".a:name)
+        let value = toupper(b:dbext_type)
+        if index(s:db_types_mv, value) == -1
+            call s:DB_warningMsg("dbext:Unknown database type: " . b:dbext_type)
+            return ""
+        else
+            call s:DB_warningMsg( "dbext:s:DB_" . b:dbext_type .
+                        \ '_' . a:name . 
+                        \ ' not found'
+                        \ )
+            return ""
+        endif
+    endif
+
+    echon 'dbext: Executing SQL at '.strftime("%H:%M")
+
+    " Could not figure out how to do this with an unlimited #
+    " of variables, so I limited this to 4.  Currently we only use
+    " 1 parameter in the code (May 2004), so that should be fine.
+    if a:0 == 0
+        return s:DB_{b:dbext_type}_{a:name}()
+    elseif a:0 == 1
+        return s:DB_{b:dbext_type}_{a:name}(a:1)
+    elseif a:0 == 2
+        return s:DB_{b:dbext_type}_{a:name}(a:1, a:2)
+    elseif a:0 == 3
+        return s:DB_{b:dbext_type}_{a:name}(a:1, a:2, a:3)
+    else
+        return s:DB_{b:dbext_type}_{a:name}(a:1, a:2, a:3, a:4)
+    endif
+endfunction
+
+function! s:DB_getTblAlias(table_name) 
+    let owner      = s:DB_getObjectOwner(a:table_name)
+    let table_name = s:DB_getObjectName(a:table_name)
+    let tbl_alias = ''
+    if s:DB_get("use_tbl_alias") != 'n'
+
+        if 'da' =~? s:DB_get("use_tbl_alias")
+            if table_name =~ '_'
+                " Treat _ as separators since people often use these
+                " for word separators
+                let save_keyword = &iskeyword
+                setlocal iskeyword-=_
+
+                " Get the first letter of each word
+                " [[:alpha:]] is used instead of \w 
+                " to catch extended accented characters
+                "
+                let initials = substitute( 
+                            \ table_name, 
+                            \ '\<[[:alpha:]]\+\>_\?', 
+                            \ '\=strpart(submatch(0), 0, 1)', 
+                            \ 'g'
+                            \ )
+                " Restore original value
+                let &iskeyword = save_keyword
+            elseif table_name =~ '\u\U'
+                let initials = substitute(
+                            \ table_name, '\(\u\)\U*', '\1', 'g')
+            else
+                let initials = strpart(table_name, 0, 1)
+            endif
+
+            if 'a' =~? s:DB_get("use_tbl_alias")
+                let tbl_alias = inputdialog("Enter table alias:", initials)
+            else
+                let tbl_alias = initials
+            endif
+        endif
+        " Following a word character, make sure there is a . and no spaces
+        let tbl_alias = substitute(tbl_alias, '\w\zs\.\?\s*$', '.', '')
+    endif
+
+    return tbl_alias
+endfunction 
+
+function! s:DB_getTitle() 
+    let no_defaults  = 0
+    let buffer_title = 0
+
+    if s:DB_get("custom_title") == ''
+        let buffer_title = '' .
+                    \ s:DB_option('T(', s:DB_get("type"),          ')  ') .
+                    \ s:DB_option('H(', s:DB_get("host"),          ')  ') .
+                    \ s:DB_option('P(', s:DB_get("port"),          ')  ') .
+                    \ s:DB_option('S(', s:DB_get("srvname"),       ')  ') .
+                    \ s:DB_option('O(', s:DB_get("dsnname"),       ')  ') .
+                    \ s:DB_option('D(', s:DB_get("dbname"),        ')  ') .
+                    \ s:DB_option('I(', s:DB_get("driver"),        ')  ') .
+                    \ s:DB_option('C(', s:DB_get("conn_parms"),    ')  ') .
+                    \ s:DB_option('P(', s:DB_get("driver_parms"),  ')  ')
+
+        if s:DB_get("integratedlogin") == '1'
+            if has("win32")
+                let buffer_title = buffer_title . 
+                            \ s:DB_option('U(', expand("$USERNAME"), ')  ') 
+            else
+                let buffer_title = buffer_title . 
+                            \ s:DB_option('U(', expand("$USER"), ')  ') 
+            endif
+        else
+            let buffer_title = buffer_title . 
+                        \ s:DB_option('U(', s:DB_get("user"), ')  ')
+        endif
+
+    else
+        let buffer_title = s:DB_get("custom_title")
+    endif
+
+    return buffer_title
+endfunction 
+
+function! dbext#DB_setTitle() 
+    let no_defaults = 0
+
+    " In order to parse a statement, we must know what database type
+    " we are dealing with to choose the correct cmd_terminator
+    if s:DB_get("buffer_defaulted") == 1
+        if s:DB_get("replace_title") == 1 && s:DB_get("type", no_defaults) != ''
+            let &titlestring = s:DB_getTitle()
+        endif
+    endif
+
+endfunction 
+
+"" Set buffer parameter value
+function! s:DB_set(name, value)
+    if index(s:all_params_mv, a:name) > -1
+        let value = a:value
+
+        " If a value of -1 is provided assume an error
+        " somewhere an abort
+        if value == -1 
+            return -1
+        endif
+
+        " Handle some special cases
+        if (a:name ==# "type")
+            " Do not check if the type already exists since
+            " performing this additional check prevents the type
+            " from being set to "@askb", so the user would never 
+            " be prompted for a value.
+            let value = toupper(value)
+        endif
+        " Profile will have to be retrieved from your vimrc
+        " and each option must be processed
+        if a:name == 'profile'
+            " Now set the connection parameters from the profile
+            if s:DB_parseProfile(value) == -1
+                return -1
+            endif
+        endif
+
+        if index(s:script_params_mv, a:name) > -1
+            let s:dbext_{a:name} = value
+        else
+            let b:dbext_{a:name} = value
+        endif
+
+        if s:DB_get("replace_title") == '1'
+            call dbext#DB_setTitle()
+        endif
+    elseif index(s:config_dbi_mv, a:name) > -1
+        if a:value."" == ""
+            call s:DB_set(a:name, s:DB_getDefault(a:name))
+        else
+            let b:dbext_{a:name} = a:value
+        endif
+        if a:name == 'DBI_commit_on_disconnect'
+            " Special case since this option must be set
+            " both in the DBI layer and the dbext plugin
+            call s:DB_DBI_setOption(a:name, a:value)
+        endif
+    elseif index(s:saved_conn_params_mv, a:name) > -1
+        " Store these parameters as script variables
+        " since only 1 should ever be active at a time
+        let s:dbext_{a:name} = a:value
+    else
+        if index(s:db_dbi_mv, a:name) > -1
+            let rc = 0
+            if s:DB_get('type') =~ '\<DBI\>\|\<ODBC\>'
+                let rc = s:DB_DBI_setOption(a:name, a:value)
+            endif
+            return rc
+        endif
+
+        call s:DB_warningMsg("dbext:Unknown parameter: " . a:name)
+        return -1
+    endif
+
+    return 0
+endfunction
+
+"" Set global variable parameter value
+function! s:DB_setGlobal(name, value)
+    let g:dbext_default_{a:name} = a:value
+
+    return 0
+endfunction
+
+"" Set buffer parameter value based on database type
+function! s:DB_setWType(name, value)
+    let var_name = b:dbext_type."_".a:name
+    call s:DB_set(var_name, a:value )
+endfunction
+
+"" Escape any special characters
+function! s:DB_escapeStr(value)
+    " Any special characters must be escaped before they can be used in a
+    " search string or on the command line
+    let escaped_str = 
+                \ substitute(
+                \     substitute(
+                \         escape(a:value, '\\/.*$^~[]'),
+                \         "\n$", 
+                \         "", ""
+                \     ),
+                \     "\n", '\\_[[:return:]]', "g"
+                \ )
+    return escaped_str
+endfunction
+
+"" Get buffer parameter value
+function! dbext#DB_listOption(...)
+    let use_defaults = 1
+
+    " Use defaults as the default for this function
+    if (a:0 > 0) && strlen(a:1) > 0
+        return s:DB_get(a:1, use_defaults)
+    endif
+
+    " Record current buffer to return to the correct one
+    let s:dbext_prev_winnr = winnr()
+    let s:dbext_prev_bufnr = bufnr('%')
+
+    let conn_params_cnt   = len(s:conn_params_mv)
+    let config_params_cnt = len(s:config_params_mv)
+    let script_params_cnt = len(s:script_params_mv)
+
+    let option_cnt  = 1
+    let option_list = 
+                \ "------------------------\n" .
+                \ "** Connection Options **\n" .
+                \ "------------------------\n"
+    for param_mv in s:all_params_mv
+        if option_cnt == (conn_params_cnt + 1) 
+            let option_list = option_list .
+                        \ "---------------------------\n" .
+                        \ "** Configuration Options **\n" .
+                        \ "---------------------------\n"
+        elseif option_cnt == (conn_params_cnt +
+                    \ config_params_cnt + 1)  
+            let option_list = option_list .
+                        \ "--------------------------\n" .
+                        \ "** Script Level Options **\n" .
+                        \ "--------------------------\n"
+        elseif option_cnt == (conn_params_cnt +
+                    \ config_params_cnt +
+                    \ script_params_cnt + 1)  
+            let option_list = option_list .
+                        \ "----------------------\n" .
+                        \ "** Database Options **\n" .
+                        \ "----------------------\n"
+        endif
+        let opt_name    = param_mv
+        try
+            let opt_value   = opt_name . ' = ' . s:DB_get(opt_name)
+        catch
+            call s:DB_errorMsg('Failed to get:'.opt_name)
+        endtry
+        let option_list = option_list . opt_value . "\n"
+        let option_cnt  = option_cnt + 1
+    endfor
+     
+    let option_list = option_list .
+                \ "---------------------\n" .
+                \ "** DBI / DBI::ODBC **\n" .
+                \ "---------------------\n"
+    for dbi_mv in s:config_dbi_mv
+        let opt_name    = dbi_mv
+        let opt_value   = opt_name . ' = ' . s:DB_get(opt_name)
+        let option_list = option_list . opt_value . "\n"
+        let option_cnt  = option_cnt + 1
+    endfor
+     
+    let option_list = option_list .
+                \ "--------------\n" .
+                \ "** Profiles **\n" .
+                \ "--------------\n"
+    for profile_mv in s:conn_profiles_mv
+        let opt_name    = profile_mv
+        " let opt_value   = opt_name . ' = ' . s:DB_get(opt_name)
+        let opt_value   = ''
+        if exists('g:dbext_default_profile_'.opt_name)
+            let opt_value = matchstr(g:dbext_default_profile_{opt_name}, 'type=\zs\w\+\ze\(:\|$\)')
+        endif
+        let option_list = option_list . opt_name . ' T(' . opt_value . ")\n"
+    endfor
+     
+    let option_list = option_list .
+                \ "-------------------------------\n" .
+                \ "** Overrides (via the vimrc) **\n" .
+                \ "-------------------------------\n"
+    " Check if the user has any profiles defined in his vimrc
+    let saveA = @a
+    redir  @a
+    silent! exec 'let'
+    redir END
+    let l:global_vars = @a
+    let @a = saveA
+
+    let dbext_default_prefix = 'dbext_default_\zs\(\w\+\)'
+    let index = match(l:global_vars, dbext_default_prefix)
+    while index > -1
+        " Retrieve the name of option
+        let opt_name = matchstr(l:global_vars, '\w\+', index)
+        if strlen(opt_name) > 0
+            let opt_value = matchstr(l:global_vars, '\s*\zs[^'."\<C-J>".']\+', 
+                        \ (index + strlen(opt_name))  )
+            if opt_name !~ 'profile_'
+                let option_list = option_list . opt_name . ' = ' . opt_value . "\n"
+            endif
+        endif
+        let index = index + strlen(opt_name)+ strlen(opt_value) + 1
+        let index = match(l:global_vars, dbext_default_prefix, index)
+    endwhile
+
+    let option_list = option_list .
+                \ "-------------------------------\n" .
+                \ "** Vim Version Information   **\n" .
+                \ "-------------------------------\n"
+    " Check if the user has any profiles defined in his vimrc
+    redir => vim_version_info
+    silent! version
+    redir END
+    let option_list = option_list . vim_version_info . "\n"
+
+    call s:DB_addToResultBuffer(option_list, "clear")
+
+    return ""
+endfunction
+
+"" Get buffer parameter value
+function! s:DB_get(name, ...)
+    " Use defaults as the default for this function
+    let use_defaults = ((a:0 > 0)?(a:1+0):1)
+    let no_default   = 0
+
+    " Most parameters are buffer specific
+    let prefix = "b:dbext_"
+
+    " These two Lists store the list of parameters
+    " that are script wide
+    if index(s:script_params_mv, a:name) > -1
+        let prefix = "s:dbext_"
+    endif
+    if index(s:saved_conn_params_mv, a:name) > -1
+        let prefix = "s:dbext_"
+    endif
+
+    if exists(prefix.a:name)
+        try
+            let retval = {prefix}{a:name} . '' "force string
+        catch
+            let retval = join({prefix}{a:name}, ',') . '' "force string
+        endtry
+    elseif use_defaults == 1
+        let retval = s:DB_getDefault(a:name)
+    else
+        let retval = ''
+    endif
+
+    if exists("b:dbext_prompting_user") && b:dbext_prompting_user != 1
+        if retval =~? "@ask"
+            let retval = s:DB_promptForParameters(a:name)
+        endif
+    endif
+
+    return retval
+endfunction
+
+"" Get buffer parameter value based on database type
+function! dbext#DB_getWType(name)
+    if exists("b:dbext_type")
+        let retval = s:DB_get(b:dbext_type.'_'.a:name)
+    else
+        let retval = ""
+    endif
+    
+    return retval
+endfunction
+
+"" Get buffer defaulting to the buffer set value 
+"" or if empty use the database type default.
+function! dbext#DB_getWTypeDefault(name)
+    let retval = s:DB_get(a:name)
+
+    if retval == "" && exists("b:dbext_type")
+        let retval = s:DB_get(b:dbext_type.'_'.a:name)
+    endif
+    
+    return retval
+endfunction
+
+"" Returns hardcoded defaults for parameters.
+function! s:DB_getDefault(name)
+    " Must use g:dbext_default_profile.'' so that it is expanded
+    if     a:name ==# "profile"                 |return (exists("g:dbext_default_profile")?g:dbext_default_profile.'':'@askb') 
+    elseif a:name ==# "type"                    |return (exists("g:dbext_default_type")?g:dbext_default_type.'':'@askb') 
+    elseif a:name ==# "integratedlogin"         |return (exists("g:dbext_default_integratedlogin")?g:dbext_default_integratedlogin.'':'0') 
+    elseif a:name ==# "user"                    |return (exists("g:dbext_default_user")?g:dbext_default_user.'':'@askb') 
+    elseif a:name ==# "passwd"                  |return (exists("g:dbext_default_passwd")?g:dbext_default_passwd.'':'@askb') 
+    elseif a:name ==# "dsnname"                 |return (exists("g:dbext_default_dsnname")?g:dbext_default_dsnname.'':'') 
+    elseif a:name ==# "srvname"                 |return (exists("g:dbext_default_srvname")?g:dbext_default_srvname.'':'') 
+    elseif a:name ==# "dbname"                  |return (exists("g:dbext_default_dbname")?g:dbext_default_dbname.'':'') 
+    elseif a:name ==# "host"                    |return (exists("g:dbext_default_host")?g:dbext_default_host.'':'') 
+    elseif a:name ==# "port"                    |return (exists("g:dbext_default_port")?g:dbext_default_port.'':'') 
+    elseif a:name ==# "extra"                   |return (exists("g:dbext_default_port")?g:dbext_default_port.'':'') 
+    elseif a:name ==# "bin_path"                |return (exists("g:dbext_default_bin_path")?g:dbext_default_bin_path.'':'') 
+    elseif a:name ==# "driver"                  |return (exists("g:dbext_default_driver")?g:dbext_default_driver.'':'') 
+    elseif a:name ==# "driver_parms"            |return (exists("g:dbext_default_driver_parms")?g:dbext_default_driver_parms.'':'') 
+    elseif a:name ==# "conn_parms"              |return (exists("g:dbext_default_conn_parms")?g:dbext_default_conn_parms.'':'') 
+    " ? - look for a question mark
+    " w - MUST have word characters after it
+    " W - CANNOT have any word characters after it
+    " q - quotes do not matter
+    " Q - CANNOT be surrounded in quotes
+    " , - delimiter between options
+    elseif a:name ==# "variable_def"            |return (exists("g:dbext_default_variable_def")?g:dbext_default_variable_def.'':'?WQ,@wq,:wq,$wq')
+    elseif a:name ==# "variable_def_regex"      |return (exists("g:dbext_default_variable_def_regex")?g:dbext_default_variable_def_regex.'':'\(\w\|'."'".'\)\@<!?\(\w\|'."'".'\)\@<!,\zs\(@\|:\a\|$\)\w\+\>')
+    elseif a:name ==# "buffer_lines"            |return (exists("g:dbext_default_buffer_lines")?g:dbext_default_buffer_lines.'':10)
+    elseif a:name ==# "use_result_buffer"       |return (exists("g:dbext_default_use_result_buffer")?g:dbext_default_use_result_buffer.'':1)
+    elseif a:name ==# "use_sep_result_buffer"   |return (exists("g:dbext_default_use_sep_result_buffer")?g:dbext_default_use_sep_result_buffer.'':0)
+    elseif a:name ==# "display_cmd_line"        |return (exists("g:dbext_default_display_cmd_line")?g:dbext_default_display_cmd_line.'':0)
+    elseif a:name ==# "prompt_for_parameters"   |return (exists("g:dbext_default_prompt_for_parameters")?g:dbext_default_prompt_for_parameters.'':1)
+    elseif a:name ==# "query_statements"        |return (exists("g:dbext_default_query_statements")?g:dbext_default_query_statements.'':'select,update,delete,insert,create,grant,alter,call,exec,merge,with')
+    elseif a:name ==# "parse_statements"        |return (exists("g:dbext_default_parse_statements")?g:dbext_default_parse_statements.'':'select,update,delete,insert,call,exec,with')
+    elseif a:name ==# "always_prompt_for_variables" |return (exists("g:dbext_default_always_prompt_for_variables")?g:dbext_default_always_prompt_for_variables.'':0)
+    elseif a:name ==# "replace_title"           |return (exists("g:dbext_default_replace_title")?g:dbext_default_replace_title.'':0)
+    elseif a:name ==# "use_tbl_alias"           |return (exists("g:dbext_default_use_tbl_alias")?g:dbext_default_use_tbl_alias.'':'a')
+    elseif a:name ==# "delete_temp_file"        |return (exists("g:dbext_default_delete_temp_file")?g:dbext_default_delete_temp_file.'':'1')
+    elseif a:name ==# "buffers_with_dict_files" |return s:dbext_buffers_with_dict_files
+    elseif a:name ==# "temp_file"               |return s:dbext_tempfile
+    elseif a:name ==# "window_use_horiz"        |return (exists("g:dbext_default_window_use_horiz")?g:dbext_default_window_use_horiz.'':'1')
+    elseif a:name ==# "window_width"            |return (exists("g:dbext_default_window_width")?g:dbext_default_window_width.'':'1')
+    elseif a:name ==# "window_use_bottom"       |return (exists("g:dbext_default_window_use_bottom")?g:dbext_default_window_use_bottom.'':'1')
+    elseif a:name ==# "window_use_right"        |return (exists("g:dbext_default_window_use_right")?g:dbext_default_window_use_right.'':'1')
+    elseif a:name ==# "window_increment"        |return (exists("g:dbext_default_window_increment")?g:dbext_default_window_increment.'':'1')
+    elseif a:name ==# "login_script_dir"        |return (exists("g:dbext_default_login_script_dir")?g:dbext_default_login_script_dir.'':'')
+    elseif a:name ==# "use_win32_filenames"     |return (exists("g:dbext_default_use_win32_filenames")?g:dbext_default_use_win32_filenames.'':'0')
+    elseif a:name ==# "dbext_version"           |return (g:loaded_dbext)
+    elseif a:name ==# "history_file"            |return (exists("g:dbext_default_history_file")?g:dbext_default_history_file.'':(has('win32')?$VIM.'/dbext_sql_history.txt':$HOME.'/dbext_sql_history.txt'))
+    elseif a:name ==# "history_bufname"         |return (fnamemodify(s:DB_get('history_file'), ":t:r"))
+    elseif a:name ==# "history_size"            |return (exists("g:dbext_default_history_size")?g:dbext_default_history_size.'':'50')
+    elseif a:name ==# "history_max_entry"       |return (exists("g:dbext_default_history_max_entry")?g:dbext_default_history_max_entry.'':'4096')
+    elseif a:name ==# "autoclose"               |return (exists("g:dbext_default_autoclose")?g:dbext_default_autoclose.'':'0')
+    elseif a:name ==# "autoclose_min_lines"     |return (exists("g:dbext_default_autoclose_min_lines")?g:dbext_default_autoclose_min_lines.'':'2')
+    elseif a:name ==# "variable_remember"       |return (exists("g:dbext_default_variable_remember")?g:dbext_default_variable_remember.'':'1')
+    elseif a:name ==# "ASA_bin"                 |return (exists("g:dbext_default_ASA_bin")?g:dbext_default_ASA_bin.'':'dbisql')
+    elseif a:name ==# "ASA_cmd_terminator"      |return (exists("g:dbext_default_ASA_cmd_terminator")?g:dbext_default_ASA_cmd_terminator.'':';')
+    elseif a:name ==# "ASA_cmd_options"         |return (exists("g:dbext_default_ASA_cmd_options")?g:dbext_default_ASA_cmd_options.'':'-nogui')
+    elseif a:name ==# "ASA_on_error"            |return (exists("g:dbext_default_ASA_on_error")?g:dbext_default_ASA_on_error.'':'exit')
+    elseif a:name ==# "ASA_SQL_Top_pat"         |return (exists("g:dbext_default_ASA_SQL_Top_pat")?g:dbext_default_ASA_SQL_Top_pat.'':'\(\cselect\)')
+    elseif a:name ==# "ASA_SQL_Top_sub"         |return (exists("g:dbext_default_ASA_SQL_Top_sub")?g:dbext_default_ASA_SQL_Top_sub.'':'\1 TOP @dbext_topX ')
+    elseif a:name ==# "ULTRALITE_bin"            |return (exists("g:dbext_default_ULTRALITE_bin")?g:dbext_default_ULTRALITE_bin.'':'dbisql')
+    elseif a:name ==# "ULTRALITE_cmd_terminator" |return (exists("g:dbext_default_ULTRALITE_cmd_terminator")?g:dbext_default_ULTRALITE_cmd_terminator.'':';')
+    elseif a:name ==# "ULTRALITE_cmd_options"    |return (exists("g:dbext_default_ULTRALITE_cmd_options")?g:dbext_default_ULTRALITE_cmd_options.'':'-nogui -ul')
+    elseif a:name ==# "ULTRALITE_on_error"       |return (exists("g:dbext_default_ULTRALITE_on_error")?g:dbext_default_ULTRALITE_on_error.'':'exit')
+    elseif a:name ==# "ULTRALITE_SQL_Top_pat"    |return (exists("g:dbext_default_ULTRALITE_SQL_Top_pat")?g:dbext_default_ULTRALITE_SQL_Top_pat.'':'\(\cselect\)')
+    elseif a:name ==# "ULTRALITE_SQL_Top_sub"    |return (exists("g:dbext_default_ULTRALITE_SQL_Top_sub")?g:dbext_default_ULTRALITE_SQL_Top_sub.'':'\1 TOP @dbext_topX ')
+    elseif a:name ==# "ASE_bin"                 |return (exists("g:dbext_default_ASE_bin")?g:dbext_default_ASE_bin.'':'isql')
+    elseif a:name ==# "ASE_cmd_terminator"      |return (exists("g:dbext_default_ASE_cmd_terminator")?g:dbext_default_ASE_cmd_terminator.'':"\ngo\n")
+    elseif a:name ==# "ASE_cmd_options"         |return (exists("g:dbext_default_ASE_cmd_options")?g:dbext_default_ASE_cmd_options.'':'-w 10000')
+    elseif a:name ==# "ASE_SQL_Top_pat"         |return (exists("g:dbext_default_ASE_SQL_Top_pat")?g:dbext_default_ASE_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "ASE_SQL_Top_sub"         |return (exists("g:dbext_default_ASE_SQL_Top_sub")?g:dbext_default_ASE_SQL_Top_sub.'':'SET rowcount @dbext_topX \1')
+    elseif a:name ==# "DB2_use_db2batch"        |return (exists("g:dbext_default_DB2_use_db2batch")?g:dbext_default_DB2_use_db2batch.'':(has('win32')?'0':'1'))
+    elseif a:name ==# "DB2_bin"                 |return (exists("g:dbext_default_DB2_bin")?g:dbext_default_DB2_bin.'':'db2batch')
+    elseif a:name ==# "DB2_cmd_options"         |return (exists("g:dbext_default_DB2_cmd_options")?g:dbext_default_DB2_cmd_options.'':'-q off -s off')
+    elseif a:name ==# "DB2_db2cmd_bin"          |return (exists("g:dbext_default_DB2_db2cmd_bin")?g:dbext_default_DB2_db2cmd_bin.'':'db2cmd')
+    elseif a:name ==# "DB2_db2cmd_cmd_options"  |return (exists("g:dbext_default_DB2_db2cmd_cmd_options")?g:dbext_default_DB2_db2cmd_cmd_options.'':'-c -w -i -t db2 -s')
+    elseif a:name ==# "DB2_cmd_terminator"      |return (exists("g:dbext_default_DB2_cmd_terminator")?g:dbext_default_DB2_cmd_terminator.'':';')
+    elseif a:name ==# "DB2_SQL_Top_pat"         |return (exists("g:dbext_default_DB2_SQL_Top_pat")?g:dbext_default_DB2_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "DB2_SQL_Top_sub"         |return (exists("g:dbext_default_DB2_SQL_Top_sub")?g:dbext_default_DB2_SQL_Top_sub.'':'\1 FETCH FIRST @dbext_topX ROWS ONLY')
+    elseif a:name ==# "INGRES_bin"              |return (exists("g:dbext_default_INGRES_bin")?g:dbext_default_INGRES_bin.'':'sql')
+    elseif a:name ==# "INGRES_cmd_options"      |return (exists("g:dbext_default_INGRES_cmd_options")?g:dbext_default_INGRES_cmd_options.'':'')
+    elseif a:name ==# "INGRES_cmd_terminator"   |return (exists("g:dbext_default_INGRES_cmd_terminator")?g:dbext_default_INGRES_cmd_terminator.'':'\p\g')
+    elseif a:name ==# "INTERBASE_bin"           |return (exists("g:dbext_default_INTERBASE_bin")?g:dbext_default_INTERBASE_bin.'':'isql')
+    elseif a:name ==# "INTERBASE_cmd_options"   |return (exists("g:dbext_default_INTERBASE_cmd_options")?g:dbext_default_INTERBASE_cmd_options.'':'')
+    elseif a:name ==# "INTERBASE_cmd_terminator"|return (exists("g:dbext_default_INTERBASE_cmd_terminator")?g:dbext_default_INTERBASE_cmd_terminator.'':';')
+    elseif a:name ==# "MYSQL_bin"               |return (exists("g:dbext_default_MYSQL_bin")?g:dbext_default_MYSQL_bin.'':'mysql')
+    elseif a:name ==# "MYSQL_cmd_options"       |return (exists("g:dbext_default_MYSQL_cmd_options")?g:dbext_default_MYSQL_cmd_options.'':'')
+    elseif a:name ==# "MYSQL_cmd_terminator"    |return (exists("g:dbext_default_MYSQL_cmd_terminator")?g:dbext_default_MYSQL_cmd_terminator.'':';')
+    elseif a:name ==# "MYSQL_version"           |return (exists("g:dbext_default_MYSQL_version")?g:dbext_default_MYSQL_version.'':'5')
+    elseif a:name ==# "MYSQL_extra"             |return (exists("g:dbext_default_MYSQL_extra")?g:dbext_default_MYSQL_extra.'':'-t')
+    elseif a:name ==# "MYSQL_SQL_Top_pat"       |return (exists("g:dbext_default_MYSQL_SQL_Top_pat")?g:dbext_default_MYSQL_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "MYSQL_SQL_Top_sub"       |return (exists("g:dbext_default_MYSQL_SQL_Top_sub")?g:dbext_default_MYSQL_SQL_Top_sub.'':'\1 LIMIT @dbext_topX ')
+    elseif a:name ==# "FIREBIRD_bin"            |return (exists("g:dbext_default_FIREBIRD_bin")?g:dbext_default_FIREBIRD_bin.'':'isql')
+    elseif a:name ==# "FIREBIRD_cmd_options"    |return (exists("g:dbext_default_FIREBIRD_cmd_options")?g:dbext_default_FIREBIRD_cmd_options.'':'')
+    elseif a:name ==# "FIREBIRD_cmd_terminator" |return (exists("g:dbext_default_FIREBIRD_cmd_terminator")?g:dbext_default_FIREBIRD_cmd_terminator.'':';')
+    elseif a:name ==# "FIREBIRD_version"        |return (exists("g:dbext_default_FIREBIRD_version")?g:dbext_default_FIREBIRD_version.'':'5')
+    elseif a:name ==# "FIREBIRD_SQL_Top_pat"    |return (exists("g:dbext_default_FIREBIRD_SQL_Top_pat")?g:dbext_default_FIREBIRD_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "FIREBIRD_SQL_Top_sub"    |return (exists("g:dbext_default_FIREBIRD_SQL_Top_sub")?g:dbext_default_FIREBIRD_SQL_Top_sub.'':'\1 FIRST @dbext_topX ')
+    elseif a:name ==# "ORA_bin"                 |return (exists("g:dbext_default_ORA_bin")?g:dbext_default_ORA_bin.'':'sqlplus')
+    elseif a:name ==# "ORA_cmd_header"          |return (exists("g:dbext_default_ORA_cmd_header")?g:dbext_default_ORA_cmd_header.'':"" .
+                        \ "set pagesize 50000\n" .
+                        \ "set wrap off\n" .
+                        \ "set sqlprompt \"\"\n" .
+                        \ "set linesize 10000\n" .
+                        \ "set flush off\n" .
+                        \ "set colsep \"   \"\n" .
+                        \ "set tab off\n\n")
+    elseif a:name ==# "ORA_cmd_options"         |return (exists("g:dbext_default_ORA_cmd_options")?g:dbext_default_ORA_cmd_options.'':"-S")
+    elseif a:name ==# "ORA_cmd_terminator"      |return (exists("g:dbext_default_ORA_cmd_terminator")?g:dbext_default_ORA_cmd_terminator.'':";")
+    elseif a:name ==# "ORA_SQL_Top_pat"         |return (exists("g:dbext_default_ORA_SQL_Top_pat")?g:dbext_default_ORA_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "ORA_SQL_Top_sub"         |return (exists("g:dbext_default_ORA_SQL_Top_sub")?g:dbext_default_ORA_SQL_Top_sub.'':'SELECT * FROM (\1) WHERE rownum <= @dbext_topX ')
+    elseif a:name ==# "PGSQL_bin"               |return (exists("g:dbext_default_PGSQL_bin")?g:dbext_default_PGSQL_bin.'':'psql')
+    elseif a:name ==# "PGSQL_cmd_options"       |return (exists("g:dbext_default_PGSQL_cmd_options")?g:dbext_default_PGSQL_cmd_options.'':'')
+    elseif a:name ==# "PGSQL_cmd_terminator"    |return (exists("g:dbext_default_PGSQL_cmd_terminator")?g:dbext_default_PGSQL_cmd_terminator.'':';')
+    elseif a:name ==# "PGSQL_SQL_Top_pat"       |return (exists("g:dbext_default_PGSQL_SQL_Top_pat")?g:dbext_default_PGSQL_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "PGSQL_SQL_Top_sub"       |return (exists("g:dbext_default_PGSQL_SQL_Top_sub")?g:dbext_default_PGSQL_SQL_Top_sub.'':'\1 LIMIT @dbext_topX ')
+    elseif a:name ==# "PGSQL_pgpass"            |return (exists("g:dbext_default_PGSQL_pgpass")?g:dbext_default_PGSQL_pgpass.'':'$HOME/.pgpass')
+    elseif a:name ==# "RDB_bin"                 |return (exists("g:dbext_default_RDB_bin")?g:dbext_default_RDB_bin.'':'mc sql$')
+    elseif a:name ==# "RDB_cmd_header"          |return (exists("g:dbext_default_RDB_cmd_header")?g:dbext_default_RDB_cmd_header.'':"".
+                \ "set line length 10000\n" .
+                \ "set page length 10000\n")
+    elseif a:name ==# "RDB_cmd_options"         |return (exists("g:dbext_default_RDB_cmd_options")?g:dbext_default_RDB_cmd_options.'':"")
+    elseif a:name ==# "RDB_cmd_terminator"      |return (exists("g:dbext_default_RDB_cmd_terminator")?g:dbext_default_RDB_cmd_terminator.'':";\n")
+    elseif a:name ==# "RDB_SQL_Top_pat"         |return (exists("g:dbext_default_RDB_SQL_Top_pat")?g:dbext_default_RDB_SQL_Top_pat.'':'\(.*\)')
+    elseif a:name ==# "RDB_SQL_Top_sub"         |return (exists("g:dbext_default_RDB_SQL_Top_sub")?g:dbext_default_RDB_SQL_Top_sub.'':'\1 LIMIT to @dbext_topX rows ')
+    elseif a:name ==# "SQLITE_bin"              |return (exists("g:dbext_default_SQLITE_bin")?g:dbext_default_SQLITE_bin.'':'sqlite')
+    elseif a:name ==# "SQLITE_cmd_header"       |return (exists("g:dbext_default_SQLITE_cmd_header")?g:dbext_default_SQLITE_cmd_header.'':".mode column\n.headers ON\n")
+    elseif a:name ==# "SQLITE_cmd_options"      |return (exists("g:dbext_default_SQLITE_cmd_options")?g:dbext_default_SQLITE_cmd_options.'':'')
+    elseif a:name ==# "SQLITE_cmd_terminator"   |return (exists("g:dbext_default_SQLITE_cmd_terminator")?g:dbext_default_SQLITE_cmd_terminator.'':';')
+    elseif a:name ==# "SQLSRV_bin"              |return (exists("g:dbext_default_SQLSRV_bin")?g:dbext_default_SQLSRV_bin.'':'osql')
+    elseif a:name ==# "SQLSRV_cmd_options"      |return (exists("g:dbext_default_SQLSRV_cmd_options")?g:dbext_default_SQLSRV_cmd_options.'':'-w 10000 -r -b -n')
+    elseif a:name ==# "SQLSRV_cmd_terminator"   |return (exists("g:dbext_default_SQLSRV_cmd_terminator")?g:dbext_default_SQLSRV_cmd_terminator.'':"\ngo\n")
+    elseif a:name ==# "SQLSRV_SQL_Top_pat"      |return (exists("g:dbext_default_SQLSRV_SQL_Top_pat")?g:dbext_default_SQLSRV_SQL_Top_pat.'':'\(\cselect\)')
+    elseif a:name ==# "SQLSRV_SQL_Top_sub"      |return (exists("g:dbext_default_SQLSRV_SQL_Top_sub")?g:dbext_default_SQLSRV_SQL_Top_sub.'':'\1 TOP @dbext_topX ')
+    elseif a:name ==# "prompt_profile"          |return (exists("g:dbext_default_prompt_profile")?g:dbext_default_prompt_profile.'':"" .
+                \ (has('gui_running')?("[Optional] Enter profile #:\n".s:prompt_profile_list):
+                \ (s:prompt_profile_list."\n[Optional] Enter profile #: "))
+                \ )
+    elseif a:name ==# "prompt_type"             |return (exists("g:dbext_default_prompt_type")?g:dbext_default_prompt_type.'':"" .
+                \ (has('gui_running')?("\nDatabase:".s:prompt_type_list):
+                \ (s:prompt_type_list."\nDatabase: "))
+                \ )
+    elseif a:name ==# "prompt_integratedlogin"  |return (exists("g:dbext_default_prompt_integratedlogin")?g:dbext_default_prompt_integratedlogin.'':'[Optional] Use Integrated Login: ')
+    elseif a:name ==# "prompt_user"             |return (exists("g:dbext_default_prompt_user")?g:dbext_default_prompt_user.'':'[Optional] Database user: ')
+    elseif a:name ==# "prompt_passwd"           |return (exists("g:dbext_default_prompt_passwd")?g:dbext_default_prompt_passwd.'':'[O] User password: ')
+    elseif a:name ==# "prompt_dsnname"          |return (exists("g:dbext_default_prompt_dsnname")?g:dbext_default_prompt_dsnname.'':'[O] ODBC DSN: ')
+    elseif a:name ==# "prompt_srvname"          |return (exists("g:dbext_default_prompt_srvname")?g:dbext_default_prompt_srvname.'':'[O] Server name: ')
+    elseif a:name ==# "prompt_dbname"           |return (exists("g:dbext_default_prompt_dbname")?g:dbext_default_prompt_dbname.'':'[O] Database name: ')
+    elseif a:name ==# "prompt_host"             |return (exists("g:dbext_default_prompt_host")?g:dbext_default_prompt_host.'':'[O] Host name: ')
+    elseif a:name ==# "prompt_port"             |return (exists("g:dbext_default_prompt_port")?g:dbext_default_prompt_port.'':'[O] Port name: ')
+    elseif a:name ==# "prompt_extra"            |return (exists("g:dbext_default_prompt_extra")?g:dbext_default_prompt_extra.'':'[O] Extra parameters: ')
+    elseif a:name ==# "prompt_bin_path"         |return (exists("g:dbext_default_prompt_bin_path")?g:dbext_default_prompt_bin_path.'':'[O] Directory for database tools: ')
+    elseif a:name ==# "prompt_login_script"       |return (exists("g:dbext_default_prompt_login_script")?g:dbext_default_prompt_login_script.'':'[O] Login Script: ')
+    elseif a:name ==# "prompt_driver"           |return (exists("g:dbext_default_prompt_driver")?g:dbext_default_prompt_driver.'':'[O] DBI driver: ')
+    elseif a:name ==# "prompt_driver_parms"     |return (exists("g:dbext_default_prompt_driver_parms")?g:dbext_default_prompt_driver_parms.'':'[O] DBI driver parameters: ')
+    elseif a:name ==# "prompt_conn_parms"       |return (exists("g:dbext_default_prompt_conn_parms")?g:dbext_default_prompt_conn_parms.'':'[O] DBI connection parameters: ')
+    " These are for name completion using Vim's dictionary feature
+    elseif a:name ==# "dict_show_owner"         |return (exists("g:dbext_default_dict_show_owner")?g:dbext_default_dict_show_owner.'':'1')
+    elseif a:name ==# "dict_table_file"         |return '' 
+    elseif a:name ==# "dict_procedure_file"     |return '' 
+    elseif a:name ==# "dict_view_file"          |return ''
+    elseif a:name ==# "inputdialog_cancel_support"       |return (exists("g:dbext_default_inputdialog_cancel_support")?g:dbext_default_inputdialog_cancel_support.'':((v:version>=602)?'1':'0'))
+    " DBI Settings
+    elseif a:name ==# "DBI_max_rows"             |return (exists("g:dbext_default_DBI_max_rows")?g:dbext_default_DBI_max_rows.'':'300')
+    elseif a:name ==# "DBI_disconnect_onerror"   |return (exists("g:dbext_default_DBI_disconnect_onerror")?g:dbext_default_DBI_disconnect_onerror.'':'1')
+    elseif a:name ==# "DBI_commit_on_disconnect" |return (exists("g:dbext_default_DBI_commit_on_disconnect")?g:dbext_default_DBI_commit_on_disconnect.'':'1')
+    elseif a:name ==# "DBI_split_on_pattern"     |return (exists("g:dbext_default_DBI_split_on_pattern")?g:dbext_default_DBI_split_on_pattern.'':"\n".'\s*\<go\>\s*'."\n")
+    elseif a:name ==# "DBI_read_file_cmd"        |return (exists("g:dbext_default_DBI_read_file_cmd")?g:dbext_default_DBI_read_file_cmd.'':'read ')
+    elseif a:name ==# "DBI_cmd_terminator"       |return (exists("g:dbext_default_DBI_cmd_terminator")?g:dbext_default_DBI_cmd_terminator.'':';')
+    elseif a:name ==# "DBI_orientation"          |return (exists("g:dbext_default_DBI_orientation")?g:dbext_default_DBI_orientation.'':'horizontal')
+    elseif a:name ==# "DBI_column_delimiter"     |return (exists("g:dbext_default_DBI_column_delimiter")?g:dbext_default_DBI_column_delimiter.'':"  ")
+    elseif a:name ==# "DBI_table_type"           |return (exists("g:dbext_default_DBI_table_type")?g:dbext_default_DBI_table_type.'':'TABLE')
+    elseif a:name ==# "DBI_view_type"            |return (exists("g:dbext_default_DBI_view_type")?g:dbext_default_DBI_view_type.'':'VIEW')
+    elseif a:name ==# "DBI_trace_level"          |return (exists("g:dbext_default_DBI_trace_level")?g:dbext_default_DBI_trace_level.'':'2')
+    " Override certain values for different DBI drivers
+    elseif a:name ==# "DBI_table_type_SQLAnywhere"       |return (exists("g:dbext_default_dbi_table_type_SQLAnywhere")?g:dbext_default_dbi_table_type_SQLAnywhere.'':'%TABLE%')
+    elseif a:name ==# "DBI_view_type_SQLAnywhere"        |return (exists("g:dbext_default_dbi_view_type_SQLAnywhere")?g:dbext_default_dbi_table_type_SQLAnywhere.'':'%VIEW%')
+    elseif a:name ==# "DBI_table_type_ASAny"             |return (exists("g:dbext_default_dbi_table_type_ASAny")?g:dbext_default_dbi_table_type_ASAny.'':'%TABLE%')
+    elseif a:name ==# "DBI_view_type_ASAny"              |return (exists("g:dbext_default_dbi_view_type_ASAny")?g:dbext_default_dbi_table_type_ASAny.'':'%VIEW%')
+    " Create additional SQL statements for the DBI layer to support listing procedures which is not supported by DBI
+    elseif a:name ==# "DBI_list_proc_SQLAnywhere"  |return (exists("g:dbext_default_DBI_list_proc_SQLAnywhere")?g:dbext_default_DBI_list_proc_SQLAnywhere.'':'select p.proc_name, u.user_name from SYS.SYSPROCEDURE as p, SYS.SYSUSERPERM as u where p.creator = u.user_id and p.proc_name like ''dbext_replace_name%'' and u.user_name like ''dbext_replace_owner%'' order by proc_name')
+    elseif a:name ==# "DBI_list_proc_ASAny"        |return (exists("g:dbext_default_DBI_list_proc_ASAny")?g:dbext_default_DBI_list_proc_ASAny.'':'select p.proc_name, u.user_name from SYS.SYSPROCEDURE as p, SYS.SYSUSERPERM as u  where p.creator = u.user_id and p.proc_name like ''%'' and u.user_name like ''%''  order by proc_name')
+    elseif a:name ==# "DBI_list_proc_Oracle"       |return (exists("g:dbext_default_DBI_list_proc_Oracle")?g:dbext_default_DBI_list_proc_Oracle.'':'select object_name, owner from all_objects  where object_type IN (''PROCEDURE'', ''PACKAGE'', ''FUNCTION'') and object_name LIKE ''dbext_replace_name%'' order by object_name')
+    elseif a:name ==# "DBI_list_proc_Sybase"       |return (exists("g:dbext_default_DBI_list_proc_Sybase")?g:dbext_default_DBI_list_proc_Sybase.'':'select convert(varchar,o.name), convert(varchar,u.name)   from sysobjects o, sysusers u  where o.uid=u.uid    and o.type=''P''    and o.name like ''dbext_replace_name%''  order by o.name')
+    elseif a:name ==# "DBI_list_proc_DB2"          |return (exists("g:dbext_default_DBI_list_proc_DB2")?g:dbext_default_DBI_list_proc_DB2.'':'select CAST(procname AS VARCHAR(40)) AS procname      , CAST(procschema AS VARCHAR(15)) AS procschema      , CAST(definer AS VARCHAR(15)) AS definer      , parm_count      , deterministic      , fenced      , result_sets   from syscat.procedures  where procname like ''dbext_replace_name%''  order by procname')
+    elseif a:name ==# "DBI_list_proc_mysql"        |return (exists("g:dbext_default_DBI_list_proc_mysql")?g:dbext_default_DBI_list_proc_mysql.'':'SELECT specific_name, routine_schema    FROM INFORMATION_SCHEMA.ROUTINES  WHERE specific_name  like ''dbext_replace_name%''    AND routine_schema like ''dbext_replace_owner%'' ')
+    elseif a:name ==# "DBI_list_proc_PGSQL"        |return (exists("g:dbext_default_DBI_list_proc_PGSQL")?g:dbext_default_DBI_list_proc_PGSQL.'':'SELECT p.proname, pg_get_userbyid(u.usesysid)   FROM pg_proc p, pg_user u  WHERE p.proowner = u.usesysid    AND u.usename  like ''dbext_replace_owner%''    AND p.proname  like ''dbext_replace_name%''  ORDER BY p.proname')
+    elseif a:name ==# "DBI_list_proc_SQLSRV"       |return (exists("g:dbext_default_DBI_list_proc_SQLSRV")?g:dbext_default_DBI_list_proc_SQLSRV.'':'select convert(varchar,o.name) proc_name, convert(varchar,u.name) proc_owner   from sysobjects o, sysusers u  where o.uid=u.uid    and o.xtype=''P''    and o.name like ''dbext_replace_name%''  order by o.name')
+    " Create additional SQL statements for the DBI layer to support creating a dictionary for procedures which is not supported by DBI
+    elseif a:name ==# "DBI_dict_proc_SQLAnywhere"  |return (exists("g:dbext_default_DBI_dict_proc_SQLAnywhere")?g:dbext_default_DBI_dict_proc_SQLAnywhere.'':'select u.user_name ||''.''|| p.proc_name from SYS.SYSPROCEDURE as p, SYS.SYSUSERPERM as u  where p.creator = u.user_id order by u.user_name, proc_name')
+    elseif a:name ==# "DBI_dict_proc_ASAny"        |return (exists("g:dbext_default_DBI_dict_proc_ASAny")?g:dbext_default_DBI_dict_proc_ASAny.'':'select u.user_name ||''.''|| p.proc_name from SYS.SYSPROCEDURE as p, SYS.SYSUSERPERM as u  where p.creator = u.user_id order by u.user_name, proc_name')
+    elseif a:name ==# "DBI_dict_proc_Oracle"       |return (exists("g:dbext_default_DBI_dict_proc_Oracle")?g:dbext_default_DBI_dict_proc_Oracle.'':'select owner||''.''||object_name from all_objects where object_type IN (''PROCEDURE'', ''PACKAGE'', ''FUNCTION'') order by object_name')
+    elseif a:name ==# "DBI_dict_proc_Sybase"       |return (exists("g:dbext_default_DBI_dict_proc_Sybase")?g:dbext_default_DBI_dict_proc_Sybase.'':'select convert(varchar,u.name)||''.''||convert(varchar,o.name)   from sysobjects o, sysusers u  where o.uid=u.uid    and o.type=''P'' order by o.name')
+    elseif a:name ==# "DBI_dict_proc_DB2"          |return (exists("g:dbext_default_DBI_dict_proc_DB2")?g:dbext_default_DBI_dict_proc_DB2.'':'select CAST(procname AS VARCHAR(40)) AS procname from syscat.procedures order by procname')
+    elseif a:name ==# "DBI_dict_proc_mysql"        |return (exists("g:dbext_default_DBI_dict_proc_mysql")?g:dbext_default_DBI_dict_proc_mysql.'':'SELECT CONCAT_WS(''.'', routine_schema,specific_name) FROM INFORMATION_SCHEMA.ROUTINES  WHERE specific_name  like ''%''    AND routine_schema like ''%'' ')
+    elseif a:name ==# "DBI_dict_proc_PGSQL"        |return (exists("g:dbext_default_DBI_dict_proc_PGSQL")?g:dbext_default_DBI_dict_proc_PGSQL.'':'SELECT pg_get_userbyid(u.usesysid)||''.''||p.proname  FROM pg_proc p, pg_user u  WHERE p.proowner = u.usesysid  ORDER BY p.proname ')
+    elseif a:name ==# "DBI_dict_proc_SQLSRV"       |return (exists("g:dbext_default_DBI_dict_proc_SQLSRV")?g:dbext_default_DBI_dict_proc_SQLSRV.'':'select convert(varchar,u.name)+''.''+convert(varchar,o.name)   from sysobjects o, sysusers u  where o.uid=u.uid    and o.xtype=''P'' order by o.name ')
+    " Create additional SQL statements for the DBI layer to support describing a procedure which is not supported by DBI
+    elseif a:name ==# "DBI_desc_proc_SQLAnywhere"  |return (exists("g:dbext_default_DBI_desc_proc_SQLAnywhere")?g:dbext_default_DBI_desc_proc_SQLAnywhere.'':'select *   from SYS.SYSPROCPARMS as pp  where pp.parmtype = 0    and pp.procname = ''dbext_replace_name''   ')
+    elseif a:name ==# "DBI_desc_proc_ASAny"        |return (exists("g:dbext_default_DBI_desc_proc_ASAny")?g:dbext_default_DBI_desc_proc_ASAny.'':'select *   from SYS.SYSPROCPARMS as pp  where pp.parmtype = 0    and pp.procname = ''dbext_replace_name''   ')
+    elseif a:name ==# "DBI_desc_proc_Oracle"       |return (exists("g:dbext_default_DBI_desc_proc_Oracle")?g:dbext_default_DBI_desc_proc_Oracle.'':'select object_name, owner from all_objects  where object_type IN (''PROCEDURE'', ''PACKAGE'', ''FUNCTION'') and object_name LIKE ''dbext_replace_name%'' order by object_name')
+    elseif a:name ==# "DBI_desc_proc_Sybase"       |return (exists("g:dbext_default_DBI_desc_proc_Sybase")?g:dbext_default_DBI_desc_proc_Sybase.'':'exec sp_help dbext_replace_owner.dbext_replace_name ')
+    elseif a:name ==# "DBI_desc_proc_DB2"          |return (exists("g:dbext_default_DBI_desc_proc_DB2")?g:dbext_default_DBI_desc_proc_DB2.'':'select ordinal      , CAST(parmname AS VARCHAR(40)) AS parmname      , CAST(typename AS VARCHAR(10)) AS typename      , length      , scale      , CAST(nulls AS VARCHAR(1)) AS nulls      , CAST(procschema AS VARCHAR(30)) AS procschema   from syscat.procparms  where procname = ''dbext_replace_name%''   order by ordinal   ')
+    elseif a:name ==# "DBI_desc_proc_mysql"        |return (exists("g:dbext_default_DBI_desc_proc_mysql")?g:dbext_default_DBI_desc_proc_mysql.'':'describe dbext_replace_owner.dbext_replace_name ')
+    elseif a:name ==# "DBI_desc_proc_PGSQL"        |return (exists("g:dbext_default_DBI_desc_proc_PGSQL")?g:dbext_default_DBI_desc_proc_PGSQL.'':'SELECT p.*   FROM pg_proc p, pg_type t, pg_language l  WHERE p.proargtypes = t.oid    AND p.prolang = t.oid    AND p.proname = ''dbext_replace_name''   ORDER BY p.pronargs  ')
+    elseif a:name ==# "DBI_desc_proc_SQLSRV"       |return (exists("g:dbext_default_DBI_desc_proc_SQLSRV")?g:dbext_default_DBI_desc_proc_SQLSRV.'':'exec sp_help dbext_replace_owner.dbext_replace_name')
+    else                                           |return ''
+    endif
+endfunction
+
+function! dbext#DB_completeSettings(ArgLead, CmdLine, CursorPos)
+    let items = copy(s:all_params_mv)
+    call extend(items, s:config_dbi_mv)
+    if a:ArgLead != ''
+        let items = filter(items, "v:val =~ '^".a:ArgLead."'")
+    endif
+    return items
+endfunction
+
+function! dbext#DB_completeVariable(ArgLead, CmdLine, CursorPos)
+    if exists('b:dbext_sqlvar_mv')
+        let items = []
+        for [k,v] in items(b:dbext_sqlvar_mv)
+            call add(items, k.'='.v)
+        endfor
+        if a:ArgLead != ''
+            let items = filter(items, "v:val =~ '^".substitute(a:ArgLead,"'","''",'g')."'")
+        endif
+        return items
+    else
+        return []
+    endif
+endfunction
+
+function! dbext#DB_completeTables(ArgLead, CmdLine, CursorPos)
+    let tables = []
+    let table_file = s:DB_get("dict_table_file" )
+
+    if table_file == ''
+        exec 'DBCompleteTables'
+        let table_file = s:DB_get("dict_table_file" )
+    endif
+
+    if filereadable(table_file)
+        let tables = readfile(table_file)
+        if a:ArgLead != ''
+            " let expr = 'v:val '.(g:omni_sql_ignorecase==1?'=~?':'=~#').' "\\(^'.base.'\\|^\\(\\w\\+\\.\\)\\?'.base.'\\)"'
+            let expr = 'v:val =~? "\\(^'.a:ArgLead.'\\|^\\(\\w\\+\\.\\)\\?'.a:ArgLead.'\\)"'
+            let tables = filter(tables, expr)
+        endif
+    endif
+    return tables
+endfunction
+
+"" Sets global parameters to default values.
+function! s:DB_resetGlobalParameters()
+
+    if !exists("g:dbext_suppress_version_warning")
+        let saveA = @a
+
+        " Check for previous options for dbext and tell the user
+        " the must update the parameters
+        redir  @a
+        silent! exec 'let'
+        redir END
+
+        if @a =~ 'db_ext'
+            call s:DB_warningMsg("You have used a previous version of db_ext. ")
+            call s:DB_warningMsg("The configuration parameters have changed.  ")
+            call s:DB_warningMsg("Please read through the dbext documentation to ")
+            call s:DB_warningMsg("determine what changes are necessary in your")
+            call s:DB_warningMsg("vimrc file.")
+            call s:DB_warningMsg("When all *db_ext* variables have been replaced")
+            call s:DB_warningMsg("with *dbext* variables this message will")
+            call s:DB_warningMsg("no longer be displayed.")
+            call s:DB_warningMsg("To suppress this message, add this to your")
+            call s:DB_warningMsg("vimrc file:")
+            call s:DB_warningMsg("let g:dbext_suppress_version_warning = 1")
+            call s:DB_warningMsg(":h dbext.txt")
+            call s:DB_warningMsg("")
+        endif
+        let @a = saveA
+    endif
+
+    return 1
+endfunction
+
+" The only buffer variable that must exist is the 
+" database type.
+function! s:DB_validateBufferParameters()
+    let no_defaults = 0
+    let rc          = -1
+
+    " If a database type has been chosen, do not prompt for connection
+    " information
+    let found = index( s:db_types_mv, s:DB_get("type", no_defaults) )
+    if found > -1
+        call s:DB_set("buffer_defaulted", "1")
+        let rc = 1
+    else
+        call s:DB_set("buffer_defaulted", "0")
+        let rc = -1
+    endif
+
+    return rc
+endfunction
+
+" Sets buffer parameters to global values. This is called when the user adds
+" new buffer to set up the buffer defaults
+function! s:DB_resetBufferParameters(use_defaults)
+    let no_defaults  = 0
+    let retval       = -2
+
+    " Reset configuration parameters to defaults
+    for param in s:config_params_mv
+        call s:DB_set(param, s:DB_get(param))
+    endfor
+
+    " Allow the user to define an autocmd to dynamically
+    " setup their connection information.
+    silent! doautocmd User dbextPreConnection
+
+    " Reset connection parameters to either blanks or defaults
+    " depending on what was passed into this function
+    " Loop through and prompt the user for all buffer
+    " connection parameters.
+    " Calling this function can be nested, so we must generate
+    " a unique IterCreate name.
+    for param in s:conn_params_mv
+        if a:use_defaults == 0
+            call s:DB_set(param, "")
+        else
+            " Only set the buffer variable if the default value
+            " is not '@ask'
+            if s:DB_getDefault(param) !=? '@ask'
+                let value = s:DB_get(param)
+                if value == -1 
+                    let retval = value
+                    break
+                else
+                    let retval = s:DB_set(param, value)
+                endif
+            endif
+        endif
+    endfor
+
+    " if retval == -1 
+    "     return retval
+    " endif
+
+    " If a database type has not been chosen, do prompt
+    " for connection information
+    if s:DB_get("type", no_defaults) == "" 
+                \ && a:use_defaults == 1
+                \ && retval == -2
+        call s:DB_promptForParameters()
+    endif
+
+    " if s:DB_get('filetype') == ''
+    "     let s:DB_set('filetype') = &filetype
+    " endif
+
+    " call s:DB_validateBufferParameters()
+    let retval = s:DB_validateBufferParameters()
+
+    return retval
+endfunction
+
+"" Returns a string containing a vim command where the named variable gets the
+" current value.
+" If value of g:dbext_type is 'MYSQL' then >
+"       s:DB_varToString("g:dbext_default_type")
+" returns >
+"       let g:dbext_type = 'MYSQL'
+" FIXME: don't forget to transform string if it contains special chars.
+" (eg: return \n instead of new line) Priority: low.
+function! s:DB_varToString(name)
+    if exists(a:name)
+        if {a:name} == ""
+            let value = '""'
+        else
+            let value = {a:name}
+        endif
+        return 'let ' . a:name . ' = "' . value . "\"\n"
+    else
+        return ""
+    endif
+endfunction
+
+"FIXME: Csin�lni kell erre egy kommandot.
+function! s:DB_getParameters(scope)
+    "scope must be 'b', 'g', 'd' (buffer, global, default)
+    if (a:scope == "b")
+        let prefix = "b:dbext_"
+    elseif (a:scope == "g")
+        let prefix = "g:dbext_"
+    elseif (a:scope == "d")
+        let prefix = "g:dbext_default_"
+    else
+        call s:DB_warningMsg("dbext:Invalid scope in parameter: '" . a:scope . "'")
+        return ""
+    endif
+    let variables = ""
+
+    for param in s:all_params_mv
+        let variables = variables . s:DB_varToString(prefix . param)
+    endfor
+
+    return variables
+endfunction
+
+function! s:DB_promptForParameters(...)
+
+    " call s:DB_set('prompting_user', 1)
+    let b:dbext_prompting_user = 1
+    let no_default = 1
+    let param_prompted = 0
+    let param_value = ''
+
+    " The retval is only set when an optional parameter name 
+    " is passed in from DB_get
+    let retval = ""
+
+    " Loop through and prompt the user for all buffer
+    " connection parameters
+    for param in s:conn_params_mv
+        if (a:0 > 0)
+            " If the specified parameter has already been prompted
+            " for, exit this loop
+            if param_prompted == 1
+                break
+            endif
+
+            " By default prompt for all parameters, unless
+            " a certain parameter name is supplied.
+            if (a:1 !=?  param)
+                continue
+            endif
+            let param_prompted = 1
+        endif
+
+        if param ==# 'type'
+            let l:old_value = 1 + 
+                        \ index(s:db_types_mv, s:DB_get(param, no_default))
+
+            let l:new_value = s:DB_getInput( 
+                        \ s:DB_getDefault("prompt_" . param), 
+                        \ l:old_value,
+                        \ "-1"
+                        \ )
+        elseif param ==# 'profile'
+            if empty(s:conn_profiles_mv)
+                continue
+            endif
+
+            let l:old_value = 1 + 
+                        \ index(s:conn_profiles_mv, s:DB_get(param, no_default))
+
+            let l:new_value = s:DB_getInput( 
+                        \ s:DB_getDefault("prompt_" . param), 
+                        \ l:old_value,
+                        \ "-1"
+                        \ )
+        elseif param ==# 'integratedlogin'
+            " Integrated login is only supported on Windows platforms
+            if !has("win32")
+                continue
+            elseif count(s:intlogin_types_mv, s:DB_get("type") ) == 0
+                " If the chosen datatype type does not support 
+                " integrated logins, do not prompt for it
+                continue
+            endif
+            let diag_prompt = s:DB_getDefault("prompt_" . param)
+            " Default the choice to 1 - the "No" button
+            " Otherwise add 1, if already selected to choose 
+            " the 2nd button - "Yes"
+            let l:old_value = (s:DB_get(param, no_default) == '' ? 0 : (s:DB_get(param, no_default)) )
+            let l:new_value = confirm( 
+                        \ diag_prompt,
+                        \ "&No\n&Yes\n&Cancel",
+                        \ (l:old_value+1)
+                        \ )
+            if l:new_value == 3
+                let l:new_value = "-1"
+            else
+                let l:new_value = l:new_value - 1
+            endif
+        else
+            if ( s:DB_get("integratedlogin") == '1' &&
+                        \ ( (param ==# 'user') || 
+                        \   (param ==# 'passwd')  )      )
+                " Ignore user and password if using integrated logins
+                continue
+            endif
+
+            let diag_prompt = s:DB_getDefault("prompt_" . param)
+            let l:old_value = s:DB_get(param, no_default)
+            let l:new_value = s:DB_getInput( 
+                        \ diag_prompt,
+                        \ l:old_value,
+                        \ "-1"
+                        \ )
+        endif
+        " If the user cancelled the input, break from the loop
+        " this is a new 602 feature
+        if l:new_value == "-1"
+            let retval = l:new_value
+            break
+        elseif l:new_value !=# l:old_value
+            " Make the comparison between the new_value and old_value
+            " case sensitive, since passwords and userids are often
+            " case sensitive.
+            " This comparison would have short circuited the change, 
+            " and ignored it considering it a non change.
+            let retval = l:new_value
+
+            if l:old_value =~ '@askg'
+                " Handle the special case of setting a global (@askg) value.
+                " There is no need to do something for the buffer (@askb) 
+                " since all changes affect the buffer variables.
+                call s:DB_setGlobal(param, l:new_value)
+            endif
+
+            if param == "profile"
+                " If using the DBI layer, drop any connections which may be active
+                " before switching profiles
+                if s:DB_get('type') =~ '\<DBI\>\|\<ODBC\>'
+                    call dbext#DB_disconnect()
+                endif
+
+                if l:new_value > 0 && l:new_value <= 
+                            \ len(s:conn_profiles_mv)
+                    let retval = s:conn_profiles_mv[(l:new_value-1)]
+                    call s:DB_set(param, retval)
+                else
+                    call s:DB_set(param, "")
+                    if l:new_value == 0 
+                        continue
+                    endif
+                endif
+
+                if strlen(s:DB_get('type')) > 0
+                    break
+                endif
+            elseif param == "type"
+                if l:new_value > 0 && l:new_value <= 
+                            \ len(s:db_types_mv)
+                    let retval = s:db_types_mv[(l:new_value-1)]
+                    call s:DB_set(param, retval)
+                else
+                    call s:DB_set(param, "") 
+                endif
+            else
+                " Force string comparison
+                if l:old_value.'' ==? '@ask'
+                    " If the default value is @ask, then do not set the 
+                    " buffer parameter, just return the value.
+                    " The next time we execute something, we will be
+                    " prompted for this value again.
+                    break
+                endif
+
+                call s:DB_set(param, l:new_value) 
+
+            endif
+        endif
+    endfor
+
+    call s:DB_validateBufferParameters()
+
+    if !has("gui_running") && v:version < 602
+        " Work around an issue with the input command and redir.  The file
+        " would be offset by the length of the previous input text.
+        " This has been fixed in Vim 6.2 but for backwards compatability, we
+        " are leaving this code as is
+        echo "\n" 
+    endif
+
+    if (s:DB_get('type') =~ '\<DBI\>\|\<ODBC\>') 
+        " If we have changed any of our connection parameters
+        " force a disconnect or dbext_dbi.vim will simply
+        " use the existing connection for this buffer.
+        call dbext#DB_disconnect()
+    endif
+
+    " call s:DB_set('prompting_user', 0)
+    let b:dbext_prompting_user = 0
+
+    return retval
+endfunction
+
+function! dbext#DB_checkModeline()
+    " Users can preset connection string options using Vim's modeline 
+    " features.
+    " For example, in a SQL file you could have the following:
+    "      -- dbext:profile=ASA_generic,user=bob
+    " See the Help for more details.
+    let rc = -1
+    if ((&modeline == '0') || (&modelines < 1))
+        return rc
+    endif
+    let saveSearch = @/
+    let pattern = 'dbext:'
+    let from_bottom_line = ((&modelines > line('$'))?1:(line('$')-&modelines))
+
+    let savePos = 'normal! '.line(".").'G'.col(".")."\<bar>"
+    silent execute "normal! 1G0\<bar>"
+    while search( pattern, 'W' )
+        if( (line(".") >= 1 && line(".") <= &modelines) ||
+                    \ (line(".") >= from_bottom_line)   )
+            let mdl_options = matchstr(getline("."), pattern . '\s*\zs\(.*\)')
+            " Based on the filetype, there could be comment indicators
+            " in the string, so we need to strip these based on the 
+            " &comments option
+            " A simple example:
+            "     /* dbext:...     */
+            let mdl_options = s:DB_stripComments(mdl_options)
+            " Since a modeline exists, clear any existing defaults
+            " connection parameters
+            let no_defaults = 0
+            let rc = s:DB_resetBufferParameters(no_defaults)
+            " if rc == -1
+            "     break
+            " endif
+
+            let rc = dbext#DB_setMultipleOptions(mdl_options)
+            if rc > -1
+                call s:DB_validateBufferParameters()
+            endif
+        else
+            if( line(".") < from_bottom_line )
+                silent exec 'normal! '.from_bottom_line.'G'.col(".")."\<bar>"
+            endif
+        endif
+    endwhile
+
+    let @/ = saveSearch
+    execute savePos
+    return rc
+endfunction
+
+function! s:DB_stripLeadFollowQuotesSpace(str)
+    " Strip leading or following quotes, single or double
+    let str = substitute(a:str, 
+                \ '^\s*'.'["'."']".'\?\(.*\)'.'\s*$',
+                \ '\1', 'g' )
+    " Had to do this in two steps since .* was too greedy and
+    " did not allows the quotes to be conditional
+    let str = substitute(str, 
+                \ '\(.*\)'.'["'."']".'$',
+                \ '\1', 'g' )
+    return str
+    return substitute(a:str, 
+                \ '^\s*'.'["'."']".'\?\(.*\)'.'["'."']".'\?\s*$',
+                \ '\1', 'g' )
+endfunction
+
+function! s:DB_stripLeadFollowSpaceLines(str)
+    " Thanks to Benji Fisher
+    " This seems to remove leading spaces on Linux:
+    "     :echo substitute(@a, '\(^\|\n\)\zs\s\+', '', 'g')
+    " And this should remove trailing spaces:  
+    "     :echo substitute(@a, '\s\+\ze\($\|\n\)', '', 'g')
+    "
+    " Remove any blank lines in the output:
+    " This substitution is tough since we are dealing with a 
+    " string, not a buffer.
+    " '^\(\s*\n\)*\    - From the beginning of the string, 
+    "                    remove any blank lines
+    " |\n\s*\n\@='     - Any middle or ending blank lines
+    " thanks to suresh govindachari and klaus bosau
+    "let stripped = substitute(a:str, 
+    "            \ '^\(\s*\n\)*\|\n\s*\n\@=', 
+    "            \ '', 'g')
+    "
+    " Hmm, the sent the CPU to 100%, unless I broke it into 2
+    " First, from each line, removing any beginning spaces by removing
+    " all newlines and spaces with just a newline
+    " let stripped = substitute(a:str, '[ \t\r\n]\+', '\n', 'g')
+    " This has the side effect of adding a blank line at the top
+    " let stripped = substitute(stripped, '^[\r\n]\+', '', '')
+    let stripped = substitute(a:str, '^[\r\n]\+', '', '')
+    " Now take care of the other end of the string
+    let stripped = substitute(stripped, '\([ \t]\+\)\([\r\n]\+\)', '\2', 'g')
+    
+    " Albie patch
+    " Unfortunately, the following substitute concats the first 2 lines, to 
+    " create a space on the first line
+    " let stripped = substitute( stripped, '^\s*\(.\{-}\)[ \t\r\n]*$', '\1\n', '' )
+    let stripped = substitute(stripped, '^\|[\n]\zs\s*\(.\{-}\)[ \t]*\ze[\r\n$]', '\1', 'g' )
+    let stripped = substitute(stripped, '^\s\+', '', '')
+    return stripped
+endfunction
+
+function! s:DB_getCommentChars()
+    let rc = 0
+    let comment_chars = ""
+    if &comments != ""
+        " Based on filetypes, determine what all the comment characters are
+        let comment_chars = &comments
+        " Escape any special characters
+        let comment_chars = substitute(comment_chars, '[*/$]', '\\&', 'g' )
+        " Convert the beginning option to a \|
+        " let comment_chars = substitute(comment_chars, '^.\{-}:', '\\|', '' )
+        " Convert remaining options a separators \|
+        let comment_chars = substitute(comment_chars, ',.\{-}:', '\\|', 'g')
+    endif
+
+    return comment_chars
+endfunction
+
+function! s:DB_stripComments(mdl_options)
+    " Put the comment characters together so that the dbext: modeline will
+    " automatically strip spaces and comments characters from the end of it.
+    let strip_end_expr = ':\?\s*\(,\|'.s:DB_getCommentChars().'\)\?\s*$'
+
+    return substitute(a:mdl_options, strip_end_expr, '', '')
+endfunction
+
+function! dbext#DB_setMultipleOptions(multi_options, ...)
+    let rc = 0
+    let multi_options = a:multi_options
+
+    for parms in a:000
+      echon ' ' . parms
+      let multi_options = multi_options . parms
+    endfor
+    " Strip leading or following quotes, single or double
+    let options_cs = s:DB_stripLeadFollowQuotesSpace(multi_options)
+
+    " replace all "\:" sequences with \!
+    let options_cs = substitute(options_cs, '\\:', '\\!', '' )
+
+    " Chose a bad separator (:), and it is too late to choose another one
+    " with the plugin available.
+    " On win32 platforms, must do something special for the bin_path
+    " parameter, since it can have C:\
+    if has("win32")
+        " Replace the : with a !, and correct it later
+        let options_cs = substitute(options_cs, 'bin_path\s*=\s*.\zs:\ze\\', 
+                    \ '!', '' )
+        let options_cs = substitute(options_cs, '\w\+_bin\s*=\s*.\zs:\ze\\', 
+                    \ '!', '' )
+        let options_cs = substitute(options_cs, 'dbname\s*=\s*.\zs:\ze\\', 
+                    \ '!', '' )
+    endif
+
+    " Special case due to regular expression syntax
+    if options_cs =~ '\<variable_def_regex\>'
+        let opt_value = substitute(options_cs, 'variable_def_regex\s*=\s*', '', '')
+        if opt_value =~ '^,'
+            let l:variable_def_regex = s:DB_get('variable_def_regex')
+            " if escape(','.l:variable_def_regex, '\\/.*$^~[]') !~ escape(opt_value, '\\/.*$^~[]')
+            if ','.l:variable_def_regex !~ escape(opt_value, '\\/.*$^~[]')
+                " Append to existing values if not already present
+                call s:DB_set('variable_def_regex', l:variable_def_regex.opt_value)
+            endif
+        else
+            call s:DB_set('variable_def_regex', opt_value)
+        endif
+    else
+        " Convert the comma separated list into a List
+        let options_mv = split(options_cs, ':')
+        " Loop through and prompt the user for all buffer connection parameters.
+        for option in options_mv
+            if strlen(option) > 0
+                " Retrieve the option name 
+                let opt_name  = matchstr(option, '.\{-}\ze=')
+                let opt_value = matchstr(option, '=\zs.*')
+                let opt_value = s:DB_stripLeadFollowQuotesSpace(opt_value)
+     
+                " replace all "\!" sequences with :
+                let opt_value = substitute(opt_value, '\\!', ':', '' )
+
+                if has("win32") && (
+                            \ opt_name ==? 'bin_path'
+                            \ || 
+                            \ opt_name =~? '\w\+_bin'
+                            \ || 
+                            \ opt_name ==? 'dbname'
+                            \ )
+                    " Now flip the ! back to a :
+                    let opt_value = substitute(opt_value, '!', ':', '')
+                endif
+                call s:DB_set(opt_name, opt_value)
+            endif
+        endfor
+    endif
+
+    return rc
+endfunction 
+
+function! s:DB_fullPath2Bin(executable_name) 
+    " If the database tools directory is not in the path
+    " then the user can specify a fully qualified address
+    " to the binaries.
+    " This can also include environment variables.
+    " So expand and replace slashes / spaces/ quotes
+    " to make this work on both windows and *nix platforms
+    if s:DB_get("bin_path") != ""
+        " Expand environment variables
+        let full_bin = expand(s:DB_get("bin_path"))
+        " Remove any double quotes
+        let full_bin = substitute( full_bin, '"', "", "g" )
+        " Remove any trailing spaces and a ending slash
+        let full_bin = substitute( full_bin, "[\\\\\/]\s*$", "", "ge" )
+        if has("win32") 
+            let full_bin = full_bin . "\\" . a:executable_name
+        else
+            let full_bin = full_bin . "/" . a:executable_name
+        endif
+        if has("win32") && full_bin =~ " "
+            let full_bin = '"' . full_bin . '"'
+        endif
+    else
+        let full_bin = a:executable_name
+    endif
+    return full_bin
+endfunction 
+"}}}
+
+" ASA exec {{{
+function! s:DB_ASA_execSql(str)
+    " All defaults are specified in the DB_getDefault function.
+    " This contains the defaults settings for all database types
+    let terminator = dbext#DB_getWType("cmd_terminator")
+
+    let output = dbext#DB_getWType("cmd_header") 
+    " Check if a login_script has been specified
+    let output = output.s:DB_getLoginScript(s:DB_get("login_script"))
+    let output = output.a:str
+    " Only include a command terminator if one has not already
+    " been added
+    if output !~ s:DB_escapeStr(terminator) . 
+                \ '['."\n".' \t]*$'
+        let output = output . terminator
+    endif
+
+    exe 'redir! > ' . s:dbext_tempfile
+    silent echo output
+    redir END
+
+    let dbext_bin = s:DB_fullPath2Bin(dbext#DB_getWType("bin"))
+
+    if s:DB_get("host") != "" || s:DB_get("port") != ""
+        let links = 'tcpip(' .
+                \ s:DB_option('host=', s:DB_get("host"), ';') .
+                \ s:DB_option('port=', s:DB_get("port"), '') .
+                \ ')'
+    else
+        let links = ""
+    endif
+    let cmd = dbext_bin .  ' ' . dbext#DB_getWType("cmd_options") . ' ' .
+                \ s:DB_option('-onerror ', dbext#DB_getWType("on_error"), ' ') .
+                \ ' -c "' .
+                \ s:DB_option('uid=', s:DB_get("user"), ';') .
+                \ s:DB_option('pwd=', s:DB_get("passwd"), ';') .
+                \ s:DB_option('dsn=', s:DB_get("dsnname"), ';') .
+                \ s:DB_option('eng=', s:DB_get("srvname"), ';') .
+                \ s:DB_option('dbn=', s:DB_get("dbname"), ';') .
+                \ s:DB_option('links=', links, ';') .
+                \ s:DB_option('', dbext#DB_getWTypeDefault("extra"), '') 
+    if has("win32") && s:DB_get("integratedlogin") == 1
+        let cmd = cmd . 
+                \ s:DB_option('int=', 'yes', ';') 
+    endif
+    let cmd = cmd .  '" ' . 
+                \ ' read ' . s:dbext_tempfile
+    let result = s:DB_runCmd(cmd, output, "")
+
+    return result
+endfunction
+
+function! s:DB_ASA_describeTable(table_name)
+    let owner  = s:DB_getObjectOwner(a:table_name)
+    let object = s:DB_getObjectName(a:table_name)
+    let owner  = ( strlen(owner) > 0 ? owner : '' ) 
+    " return s:DB_ASA_execSql("call sp_jdbc_columns('".object."', '".owner."');")
+    let sql =  ''.
+                \ "select * ".
+                \ "  from SYS.SYSCOLUMNS as sc ".
+                \ " where sc.tname = '".object."' "
+                " \ "select sc.creator ".
+                " \ "     , sc.tname ".
+                " \ "     , sc.cname ".
+                " \ "     , sc.coltype ".
+                " \ "     , sc.in_primary_key ".
+                " \ "     , sc.nulls ".
+                " \ "     , sc.length ".
+                " \ "     , sc.default_value ".
+                " \ "     , sc.colno ".
+                " \ "  from SYS.SYSCOLUMNS as sc ".
+                " \ " where sc.tname = '".object."' "
+
+    if owner != ''
+        let sql = sql .
+                    \" and sc.creator = '".owner."' "
+    endif
+    let sql = sql .
+                \ " order by sc.colno asc "
+    return s:DB_ASA_execSql(sql)
+endfunction
+
+function! s:DB_ASA_describeProcedure(proc_name)
+    let owner  = s:DB_getObjectOwner(a:proc_name)
+    let object = s:DB_getObjectName(a:proc_name)
+    let owner  = ( strlen(owner) > 0 ? owner : '' ) 
+    " return s:DB_ASA_execSql("call sp_sproc_columns('".object."', '".owner."');")
+    let sql =  ''.
+                \ "select * ".
+                \ "  from SYS.SYSPROCPARMS as pp ".
+                \ " where pp.parmtype = 0 ".
+                \ "   and pp.procname = '".object."' "
+
+    if owner != ''
+        let sql = sql .
+                    \" and pp.creator = '".owner."' "
+    endif
+    " let sql = sql .
+    "             \ " order by pp.parm_id asc "
+    return s:DB_ASA_execSql(sql)
+    " let sql =  ''.
+    "             \ "select u.user_name ".
+    "             \ "     , p.proc_name ".
+    "             \ "     , pp.parm_name ".
+    "             \ "     , d.domain_name ".
+    "             \ "     , d.".'"precision" '.
+    "             \ "     , pp.width ".
+    "             \ "     , pp.scale ".
+    "             \ "     , IFNULL(pp.".'"default",'." 'Y', 'N') as allows_nulls ".
+    "             \ "     , CASE  ".
+    "             \ "       WHEN (pp.parm_mode_in = 'Y' AND pp.parm_mode_out = 'Y') THEN 'IO' ".
+    "             \ "       WHEN (pp.parm_mode_in = 'Y') THEN 'I' ".
+    "             \ "       ELSE 'N' ".
+    "             \ "       END as in_out ".
+    "             \ "     , pp.parm_id ".
+    "             \ "  from SYS.SYSPROCEDURE as p ".
+    "             \ "     , SYS.SYSPROCPARM as pp ".
+    "             \ "     , SYS.SYSDOMAIN as d ".
+    "             \ "     , SYS.SYSUSERPERM as u ".
+    "             \ " where p.proc_id = pp.proc_id ".
+    "             \ "   and pp.domain_id = d.domain_id ".
+    "             \ "   and pp.parm_type = 0 ".
+    "             \ "   and p.creator = u.user_id ".
+    "             \ "   and p.proc_name = '".object."' "
+
+    " if owner != ''
+    "     let sql = sql .
+    "                 \" and u.user_name = '".owner."' "
+    " endif
+    " let sql = sql .
+    "             \ " order by pp.parm_id asc "
+    " return s:DB_ASA_execSql(sql)
+endfunction
+
+function! s:DB_ASA_getListTable(table_prefix)
+    let owner      = s:DB_getObjectOwner(a:table_prefix)
+    let table_name = s:DB_getObjectName(a:table_prefix)
+    let sql = ''.
+                \ "select tname, creator " .
+                \ "  from SYS.SYSCATALOG " .
+                \ " where tname   like '" . table_name . "%' ".
+                \ "   and creator like '" . owner . "%' ".
+                \ " order by tname"
+    return s:DB_ASA_execSql(sql)
+    " return s:DB_ASA_execSql("call sp_jdbc_tables('" .
+    "             \ table_name .
+    "             \ "%', '" .
+    "             \ owner .
+    "             \ "%');")
+endfunction
+
+function! s:DB_ASA_getListProcedure(proc_prefix)
+    let owner   = s:DB_getObjectOwner(a:proc_prefix)
+    let object  = s:DB_getObjectName(a:proc_prefix)
+    let sql = ''.
+                \ "select p.proc_name, u.user_name " .
+                \ "  from SYS.SYSPROCEDURE as p ".
+                \ "     , SYS.SYSUSERPERM as u ".
+                \ " where p.creator = u.user_id ".
+                \ "   and p.proc_name like '".object."%' ".
+                \ "   and u.user_name like '".owner."%' ".
+                \ " order by proc_name"
+    return s:DB_ASA_execSql(sql)
+    " return s:DB_ASA_execSql(
+    "             \ "call sp_jdbc_stored_procedures(null, null, ".
+    "             \ "'".a:proc_prefix."%');")
+endfunction
+
+function! s:DB_ASA_getListView(view_prefix)
+    let owner      = s:DB_getObjectOwner(a:view_prefix)
+    let view_name  = s:DB_getObjectName(a:view_prefix)
+    let query      = 
+                \ "SELECT viewname, vcreator ".
+                \ " FROM SYS.SYSVIEWS ".
+                \ " WHERE viewname LIKE '".view_name."%'"
+    if strlen(owner) > 0
+        let query = query .
+                    \ "   AND vcreator = '".owner."' ".
+                    \ " ORDER BY vcreator, viewname;"
+    else
+        let query = query .
+                    \ " ORDER BY vcreator, viewname;"
+    endif
+    return s:DB_ASA_execSql(query)
+endfunction 
+
+function! s:DB_ASA_getListColumn(table_name) 
+    let owner      = s:DB_getObjectOwner(a:table_name)
+    let table_name = s:DB_getObjectName(a:table_name)
+    let query = ''.
+                \ "select cname ".
+                \ "  from SYS.SYSCOLUMNS as sc ".
+                \ " where sc.tname = '".table_name."' "
+    if strlen(owner) > 0
+        let query = query .
+                    \ "   AND sc.creator = '".owner."' "
+    endif
+    let query = query .
+                \ " ORDER BY colno"
+    let result = s:DB_ASA_execSql( query )
+    return s:DB_ASA_stripHeaderFooter(result)
+endfunction 
+
+function! s:DB_ASA_stripHeaderFooter(result)
+    " Strip off column headers ending with a newline
+    let stripped = substitute( a:result, '\_.*-\s*'."[\<C-J>]", '', '' )
+    let g:dbext_rows_affected = matchstr(stripped, '\((\)\?\(First\s\+\)\?\zs\d\+\ze row')
+    " Strip off query statistics
+    let stripped = substitute( stripped, '\((\)\?\(First\s\+\)\?\d\+ row\_.*', '', '' )
+    " Strip off trailing spaces
+    " let stripped = substitute( stripped, '\(\<\w\+\>\)\s*', '\1', 'g' )
+    let stripped = substitute( stripped, '\(\<\w\+\>\)\s*\(\n\)', '\1\2', 'g' )
+    " Strip blank lines
+    let stripped = substitute( stripped, '\(\n\)\(\n\)', '', 'g' )
+    return stripped
+endfunction 
+
+function! s:DB_ASA_getDictionaryTable() 
+    let result = s:DB_ASA_execSql(
+                \ "select ".(s:DB_get('dict_show_owner')==1?"creator||'.'||":'')."tname " .
+                \ "  from SYS.SYSCATALOG " .
+                \ " order by ".(s:DB_get('dict_show_owner')==1?"creator, ":'')."tname"
+                \ )
+    return s:DB_ASA_stripHeaderFooter(result)
+endfunction 
+
+function! s:DB_ASA_getDictionaryProcedure() 
+    let result = s:DB_ASA_execSql(
+                \ "SELECT ".(s:DB_get('dict_show_owner')==1?"sup.user_name||'.'||":'')."sp.proc_name " .
+                \ "  FROM SYS.SYSPROCEDURE sp, SYS.SYSUSERPERM sup  " .
+                \ " WHERE sp.creator = sup.user_id  " .
+                \ " ORDER BY ".(s:DB_get('dict_show_owner')==1?"sup.user_name, ":'')."sp.proc_name "
+                \ )
+    return s:DB_ASA_stripHeaderFooter(result)