sponsor Vim development Vim logo Vim Book Ad

dbext.vim : Provides database access to many DBMS (Oracle, Sybase, Microsoft, MySQL, DBI,..)

 script karma  Rating 1319/387, Downloaded by 35940  Comments, bugs, improvements  Vim wiki

created by
Peter Bagyinszki
script type
This plugin contains functions/mappings/commands to enable Vim to access several databases.

Current databases supported are:
ODBC / Perl DBI (Any database with a Perl DBI driver)
Oracle Rdb (VMS)
SAP Sybase SQL Anywhere (SA/ASA)
SAP Sybase IQ (ASA)
SAP Sybase Adaptive Server Enterprise (ASE)
SAP Sybase UltraLite (UL)
Microsoft SQL Server

For Perl's DBI layer if the database you are using is not *natively* supported by dbext, but has a DBI interface, dbext's standard feature set is available.  For those already using dbext, the DBI interface should provide a performance boost when running statements against your database.  DBI also provides an ODBC bridge, therefore any ODBC compliant database is also accessible.

NOTE: As of version 4.0 this plugin requires Vim 7.
Version 5.0 supports Vim 7's autoload feature.
Version 25.0 supports Vim 8's Job / Channel asynchronous feature.

dbext provides a common interface between your editor and a database.  If your company/project moves onto a new database platform, there is no need to learn the new databases tools.  While editing your SQL (and without leaving Vim) you can execute database commands, run queries, display results, and view database objects.  dbext understands various programming languages, and can parse and prompt the user for [host] variables and execute the resulting statement.  See below for more details.

Adds a menu for the common commands for gvim users.

Some of the features that are supported:

A tutorial has been added to help you become familiar with the features of the plugin, :h dbext-tutorial.
If you dislike reading docs, then at a minimum follow the tutorial.  It will give you the basics of the features and introduce some "best" practices, like creating connection profiles.

Connection Profiles
You can create as many profiles as you like in your vimrc.  Each profile specifies various connection information.  Each buffer can be connected to a different database.   The plugin will automatically prompt the user for connection information.  If you have defined profiles in your vimrc, for ease of use,  you can choose from a numbered list.

Adding connection profiles is the best way to use dbext, :h dbext.txt has lots of examples of different profiles for different databases.
     let g:dbext_default_profile_myASA = 'type=ASA:user=DBA:passwd=SQL'
     let g:dbext_default_profile_mySQLServer = 'type=SQLSRV:integratedlogin=1:srvname=mySrv:dbname=myDB'
     let g:dbext_default_profile_mySQL = 'type=MYSQL:user=root:passwd=whatever:dbname=mysql'
     let g:dbext_default_profile_mySQL_DBI = 'type=DBI:user=root:passwd=whatever:driver=mysql:conn_parms=database=mysql;host=localhost'
     let g:dbext_default_profile_myORA = 'type=ORA:srvname=zzz42ga:user=john:passwd=whatever'

Assuming you work on many different projects, you can automatically have dbext choose the correct database connection profile by adding autocmds that use the filesystem path to choose the correct profile:

     augroup project1
         " Automatically choose the correct dbext profile
         autocmd BufRead */projectX/sql/* DBSetOption profile=myASA
     augroup end

     augroup project2
         " Automatically choose the correct dbext profile
         autocmd BufRead */projectY/* DBSetOption profile=myORA
     augroup end

Or from the menu or the maps created you can choose a profile at any time.

SQL History
As of version 3.0, dbext maintains a history file which is shared between multiple instances of Vim.  A statement added in one instance of Vim will be immediately available in a different instance of Vim on the same computer.  To re-run a statement you can either press <enter> on the line, or if you prefer the mouse you can double click on the statement.

Modeline Support
Similar to Vim modelines, you can specify connection information as comments within your buffers.  To prevent sensitive information (i.e. passwords) from being visible, you can specify a connection profile as part of your modeline.  

Object Completion
dbext ties into Vim dictionary feature.  You can complete table names, procedure names and view names using the i_CTRL-X_CTRL-K feature.

Viewing Lists of Objects
You can browse through the various objects in the database you are connected to and specify wildcard information.  For example you can say, "Show me all tables beginning with 'ml_' ".  These objects are currently supported: Tables, Procedures, Views,  Columns (for a table).

Result Buffer
The output from any of the commands is placed into a new buffer called Result.  In the event of an error, both the error and the command line is included for inspection.

There are many maps created for convenience.  They exist for most modes (command, visual and insert).

Place the cursor on a word, and invoke the default mapping (or menu) and a Result buffer will open with the contents of the table displayed (i.e. select * from <word>.  Optionally you can be prompted for the table name, and a WHERE clause.

Describe a table (see column names and datatypes).

Describe a stored procedure (see input and output datatypes).

Visually highlight statements and execute them against the database.

Parsing Statements
By default any statement will be parsed looking for input parameters (host variables), if any are found you are prompted to enter a suitable value for the parameter.  This option can be turned off either globally or on a per
buffer basis.
        SELECT first_name, city
          FROM customer
         WHERE last_name    = @name
In the case you will be asked for a value for @name.  The rules for defining input parameters are customizable either globally or on a per buffer basis.  The rules for finding these variables can be setup as standard Vim regular expressions.  So if you can find the variables using /, you can easily customize your own settings using your own naming conventions.  See help file for more details.

FileType Support
SQL can be used from a variety of languages.  Each development language (PHP, Perl, Java, ...) language has different syntax for creating SQL statements that are sent to the database.  dbext has support for several
different filetypes, so that it can understand and correctly parse a SQL statement.

The current supported languages are:
        PHP, Java, JSP, JavaScript, JProperties, Perl, SQL, Vim

For example assume you had the following Java code:
String mySQL =
    "SELECT s.script, ts.event, t.name                  " +
    "     , s.script_language, sv.name                  " +
    "  FROM ml_script s, ml_table_script ts, ml_table t " +
                "     , ml_script_version sv                        " +
    " WHERE s.script_id   = " + script_version +
    "   AND ts.version_id = "+obj.method() +
    "   AND ts.table_id   = t.table_id                  ";

If you visually select from the "SELECT ... to the "; and ran
:'<,'>DBExecSQL    (or used the default map <Leader>se)

The Java filetype support would concatenate each individual string into one
single string.  In this case it removed the " + " and concatenated  the
lines to result in the following (assuming this is on one line):
       SELECT s.script, ts.event, t.name , s.script_language, sv.name
       FROM ml_script s, ml_table_script ts, ml_table t
                  , ml_script_version sv
      WHERE s.script_id   = " + script_version + "
        AND ts.version_id = "+obj.method() +"
        AND ts.table_id   = t.table_id

Next, it will prompt you for replacement values for the various variables or  objects you used in the string.
Assuming you had the default behaviour turned on, you would be prompted  to supply a value for:
                " + script_version + "
                "+obj.method() +"

So assuming you entered:

Then the resulting string sent to your database would be (again, this would technically be on one line):
       SELECT s.script, ts.event, t.name , s.script_language, sv.name
       FROM ml_script s, ml_table_script ts, ml_table t
                  , ml_script_version sv
      WHERE s.script_id   = 100
        AND ts.version_id = 'Project_Yahoo'
        AND ts.table_id   = t.table_id

You did not have to test your SQL by cutting and pasting it into a separate tool and replacing all the object and host variables yourself.  Just by visually selecting the string and running the command DBExecSQL (or the default mapping <Leader>se) the SQL statement was executed against the database and allowed to you enter host variables.

Additional Commands
DBExecSQL - Enter any command you want sent to the database
DBExecRangeSQL - Enter any range of statements you want executed
Select  - Enter the remainder of a select (ie :Select * from customer)
Call  - Call a stored procedure
Update  - Enter the remainder of an update
Insert  - Enter the remainder of an insert
Delete  - Enter the remainder of an delete
Drop    - Enter the remainder of a drop
Alter   - Enter the remainder of an alter
Create  - Enter the remainder of a create
install details
The zip file contains the necessary path structure.

On *nix, unzip into:

On Windows unzip into:


To update the Vim Help, run:
:helptags $HOME/.vim/doc  (Unix)
:helptags $VIM/vimfiles/doc  (Windows)

The autoload/SQLComplete.vim file uses dbext.vim for dynamic code completion.  This file has been included with dbext.vim but it is normally included with the standard Vim runtime.  David Fishburn is also the author of this plugin.  It was enhanced to support SQL objects with spaces.  It can also be downloaded separately from here: http://www.vim.org/scripts/script.php?script_id=1572

David Fishburn, for issues please post to the Vim mailing list, or to David directly.  
:h dbext.txt has contact details.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
dbext_2600.zip 26.00 2017-11-17 8.0 Peter Bagyinszki New Features
- New option g:dbext_default_job_show_msgs to control whether information messages are displayed when starting and stop jobs.  Regular status messages continue to display.
- New option g:dbext_default_job_pipe_regex to control how to identify and strip piped in files and specify it separately via job options.
- Renamed option g:dbext_default_use_jobs to g:dbext_default_job_enable to better support tab completion for the DBSetOption command.
Bug Fixes
- Also check for 'timers' when checking for job support.
- Revamped job support.  Tested on Windows, Linux and OSX.  Works on long running and very short jobs where it was erratic on first release.
dbext_2500.zip 25.00 2017-01-31 7.2 Peter Bagyinszki Posted by David Fishburn

New Features
- Added support for using Vim's Job / Channel feature for asynchronous execution.  If the job fails to start, the usual synchronous way of launching the process happens (after displaying a message).  The main purpose for this feature is to allow you to continue editing your files while waiting for the results from SQL statements to complete.  Prior to Vim's Job feature, this was a synchronous process which could interrupt your development needlessly.

- New commands DBJobStatus, DBJobStop, DBJobTimerStart, DBJobTimerStop.

- New options g:dbext_default_use_jobs defaults to 1 (enabled),  g:dbext_default_job_status_update_ms defaults to 2000.
Bug Fixes
- None
dbext_2400.zip 24.00 2016-09-11 7.2 Peter Bagyinszki Posted by David Fishburn

New Features
- Added missing menu items for Execute All (sea), Execute Line (sel), Execute Previous Visual Selection (sep) (pull #18) (Raphaël Bade)

- When using ?s as input parameters, these can now be remembered and used when saving previous values when executing the query.

- Additional examples of connecting to Oracle using DBI/ODBC without a TNSNAMES entry.

- Strip off ending cmd terminators for the DBI database type as some databases (Oracle) complain about them (Bruce Hunsaker).

- For native Oracle connections, when retrieving database objects (tables, procedures, columns, ...) ignore case (Dimitri Belov).

Bug Fixes
- For Java, CSharp, JSP, HTML and JavaScript files, remove line continuation (backslash) characters before sending request to database.

- Better error handling for the DBI / ODBC databases (Michael Graham, Bruce Hunsaker, Dimitri Belov, Will Wyatt).

- The @ask[bg] parameter was not supported properly in later releases (Richard Tsai, Nan Jia).

- Vim error - Invalid range reported for the SQL history (Bruce Hunsaker).

- DBI / ODBC CommitOnDisconnect driver parameter is not supported by all drivers, handle cleanly (Dimitri Belov).

- DBI / ODBC Disconnect reported a Vim error (Dimitri Belov).
dbext_2300.zip 23.00 2016-01-04 7.2 Peter Bagyinszki Posted by David Fishburn

New Features
- Added a new database, CrateIO (Mathias Fussenegger)
- CRATE native database type and Crate via DBI are supported
- Updated the DBI SQLAnywhere procedure list to respect the option of whether to include the object owner names
- Added a new public function, DB_DictionaryDelete, to be used by the OMNI SQL Completion plugin (autoload/sqlcomplete.vim, which is part of Vim)
Bug Fixes
- helptags reported duplicate tag MyProjectDir, updated documentation as a work around as there is no way to escape the real syntax (pull #3) (mexpolk)
- For PGSQL, use the "schemaname" column rather than "tableowner" (pull #15) (Stefan Litsche)
dbext_2200.zip 22.00 2015-08-10 7.2 Peter Bagyinszki Posted by David Fishburn

New Features
- Overhauled the prompting for SQL statement variable substitution (i.e. host variables, named parameters, question marks, ...).  The actions and user interface are hopefully more clear, useful and efficient.  For a full updated tutorial on how it works see :h dbext-tutorial-variables

- Saved variables can now hold multiple values for the same parameter, see :h dbext-tutorial-variables for how it works.

- Added C++ language support for variables (pull #12) (Anatolii Sakhnik).

- Added the ability to specify special characters (i.e. "\t") for column delimiters when using ODBC or DBI database types (Michael Krnac).

- Added new option, "passwd_use_secret", which is used when entering a password, if the value should be masked.  When using a GUI version of Vim, the prompt is not displayed in a dialog unlike the other parameters.  This option is OFF (0) by default. (pull #13) (petteja)

- Added new option, "strip_into", which is used when executing statements which have variable assignments using the INTO clause.  To test these queries, you need to remove the INTO clause so that when they execute the query you can see the result set returned.  This was on for all databases, but for TransactSQL or TSQL databases like SQLSRV and ASE, stripping the INTO clause may be the wrong action.  Now it can be controlled using this setting.  This can also be set / overridden using DBSetOption strip_into=1 or as part of a dbext profile.

- Added new option, "strip_at_variables", which is executing statements which have variable assignments in the SELECT list instead of the INTO clause.  To test these queries, you need to remove the assignments when they execute to see the result set returned.  This was on for all databases, but for TransactSQL or TSQL databases like SQLSRV and ASE, stripping the variable assignments in the SELECT list is required. This can be controlled via this setting.  This can also be set / overridden using DBSetOption strip_at_variables=1 or as part of a dbext profile.
Bug Fixes
- Minor correction to DBSetVar example (Cedric Simon).

- When deleting a buffer, all syntax highlighting of your existing buffer is sometimes lost, which was a problem with one of the
  dbext autocmds (Anatolii Sakhnik).

- Update Postgres get column list join conditions (pull #9) (Dickson S. Guedes).

- dbext autocmd for checking for modelines messed up the jumplist (Justin M. Keyes)
dbext_2100.zip 21.00 2015-02-04 7.0 Peter Bagyinszki Posted by David Fishburn (maintainer)

New Features
- Added new database, SAP Sybase IQ.

- Added ability to describe SAP HANA stored procedures using DBI/ODBC.

- Added new command, DBProfilesRefresh, which will repopulate the profile list from your global variables without having to restart Vim.

- Updated dbext profiles and modelines to accept special characters (\t) as the column delimiter for DBI connections (Josef Fortier).
Bug Fixes
- Sometimes after setting a connection profile would still prompt you the first time you attempted to use the connection.

- For PostgreSQL, check for .pgpass on *nix variants and pgpass.conf on windows (Collin Peters).

- Some connection parameters were overridden incorrectly when first applying the dbext_default_profile (Lyude, Martin Chabot, Will Wyatt, Bruno Sutic).

- Worked around an issue with the vim-gitgutter dbext plugin (airblade).

- There were 3 places where we fetch Vim's variables to check for dbext profiles and other dbext settings.  These have changed these to fetch only Vim's global variables to reduce the amount returned and hopefully increase the response time (Michael Jansen).
dbext_2000.zip 20.00 2013-09-25 7.0 Peter Bagyinszki Posted by David Fishburn (maintainer)

New Features
- Added new DBI/ODBC option DBI_max_column_width to restrict the width displayed in the DBI result window (Luke Mauldin).

- Improved the pattern used to find the query under the cursor.  Besides finding the command terminator, it will also look for the first blank line or the end of the file (Jason Quirk).

- The dbext menu now uses the maps rather than calls to the commands. A new option will control this behaviour, g:dbext_map_or_cmd.

- Changed the default SQLite binary to be sqlite3 instead of sqlite (Greg Kapfhammer).

- Added a profile example for using the "sqsh" binary to connect to SQL Server instead of "osql" (Brian Iván Martínez).

- The cmd_terminator displayed under Connection Options in the DBGetOption output was always blank.

- Improved support for SAP HANA database, pulling objects from the system catalogue.
Bug Fixes
- Controlling the DBI max rows (:DBSetOption DBI_max_rows=100) and DBI column separator did not work on a per buffer basis.

- Undefined variable, s:dbext_prev_winnr, was reported when using DBI/ODBC connections through the sqlComplete plugin and completing objects which require an active database connection (i.e. Tables,  Procedures, ...) which had failed to connect to the database.

- dbext was not prompting for ? parameters in PHP files.  This also affected all languages (Jérémie).

- Changing a database's global cmd terminator was not necessarily picked up when using that database type (Jason Quirk).

- ODBC or DBI could report an error about using length() instead of scalar() (Micah Duke).

- Various errors on Linux with DBI (Micah Duke).

- Using the console version of Vim displayed a number of "debug" messages during initialization.

dbext_1900.zip 19.0 2013-05-01 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- Added support for parsing C# files (Raul Segura Acevedo).
- Updated the PostgreSQL message when the .pgpass file is missing (Dav Clark).
Bug Fixes
- When prompting for connection parameters a second time, the previously chosen profile number was not defaulted.
- If a dbext login script was stored in the $HOME directory it would never be found (Tim Teufel).
- The first host variable was prompted for replacement, but the second one was not (Stanimir Mladenov).
- Selecting a visual region with leading and ending double quotes (like a table name) could report invalid arguments for the following commands: DBSelectFromTable, DBSelectFromTableTopX, DBDescribeTable, DBDescribeProcedure, DBListColumn
- For DB2 on the mainframe the command line utilities do not support the -t switch.  If you override the buffer specific cmd_terminator setting and set this value to an empty string the -t will be left off.  This can be most easily specified in a dbext connection profile (Michael McDermott):
     let g:dbext_default_profile_MyDB2 = 'type=DB2:user=me:passwd=mypass:dbname=SSD:cmd_terminator='
  Or while within a buffer:
     DBSetOption cmd_terminator=
     DBSetOption cmd_terminator=;
dbext_1800.zip 18.0 2012-11-28 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- Added support for parsing C# files (Raul Segura Acevedo).
Bug Fixes
- Changed the Oracle calls to SQLPlus from using single quotes to using double quotes (David Sweeney).
- The <Leader>sbp and <Leader>tcl mapping were missing with version 17.00.
- The DBI interface could report: "E15: Invalid expression" when retrieving table lists from DB2, but this could also affect other SQL commands that returned strings surrounded in double quotes (Charles McGarvey).
dbext_1700.zip 17.0 2012-10-10 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- Added new database type, the SAP HANA in memory database.

- Added new option, ignore_variable_regex, which is used when parsing your statement for replacable input parameters (i.e. placeholders for prepared statements).  Certain variables need to be skipped (for example when running a CREATE PROCEDURE statement) to leave the logic inside the stored procedure intact.  This option allows the user finer control over the regex used to decide which SQL syntax should be skipped.

- Added new option, statement_starts_line, which is used when deciding if the query should be parsed for input parameters.  Certain filetypes assume the statements can be embedded within strings (like in Java, PHP, Perl and so on).

- When parsing PHP and Java files, leading and trailing quotes are stripped automatically when executing the query, which could lead to incorrect results.  First check if there is a leading quote.  If so, then only strip the corresponding closing quote.

- Updated documentation describing the default regex for variable_def_regex.
- Added new option g:dbext_map_prefix which defaults to <Leader>s, this allows you to customize the start of all the default maps (Daniel Hahler).
Bug Fixes
- The default value for variable_def_regex, did not properly escape the $, which lead to some query parameters being skipped when executing SQL.

- It was impossible to search and replace input parameters within a query if the parameter was enclosed in single quotes.  The above new features were required to make this possible (Joshua Dennis).

- DBCompleteTable, DBCompleteProcedure, DBCompleteView would always recreate the object list.  If it has already been created, it should simply reuse what was available.  To force the recreation you add the bang to the command: DBCompleteTable!, DBCompleteProcedure!, DBCompleteView!.

- Even with the checks it was possible for dbext to report:  E227: mapping already exists for ... when creating maps where the mapping already exists (Daniel Hahler).
dbext_1600.zip 16.0 2012-06-12 7.0 Peter Bagyinszki Posted by David Fishburn

Bug Fixes
- For Oracle databases, the SQLPlus command had unmatched quotation marks which could lead to errors displayed by dbext indicating it could not open the file to execute the SQL (JustinF Zhang).
dbext_1500.zip 15.0 2012-05-02 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- A new database confirguration parameter, g:dbext_default_DBTYPE_extra, is available to allow the user to customize command line parameters passed to the database binary used to execute the statement.  This can be overriden affecting all new connections via your .vimr.  Or for a specific buffer via connection profile or :DBPromptForBufferParameters (Ken Inglis, Michael Berkowski).
Bug Fixes
- The dbext menu for List Variables displayed the wrong mapping.
- For SQLite databases, if no database is specified now a warning message is displayed instead of an error message.
dbext_1400.zip 14.0 2012-04-05 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- Added support for using extended connection strings with Oracle and SQLPlus Fredrik Acosta).

- Added a new buffer option to specify which filetype dbext should use when parsing the query.  If an existing language already works as you need you can tell dbext to use it via the modeline or DBSetOption (Albie Janse van Rensburg).

- Added an example of a function I use to execute blocks of stored procedures using dbext's commands.

- For PostgreSQL, dbext will check for the existance of a .pgpass file.  If not found, execution will abort and a warning message will be displayed.  By default $HOME/.pgpass will be validated (Frank Schwach).
Bug Fixes
- When closing or deleting buffers it was possible to loose syntax, filetype and hidden settings (Alexey Radkov).

- Parsing VisualBasic and Basic variables let to errors in DB_parseVB (Albie Janse van Rensburg).

- Generating a column list for an ASA database left an extra , at the end of the list.  This also affected the SQLComplete plugin.
dbext_1300.zip 13.0 2011-06-13 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- Added new command, DBDisconnectAll, for DBI/ODBC.
- DBDisconnect for DBI/ODBC now can accept an optional parameter for the buffer you wish disconnected.
- DBListConnections also includes the buffer filename in it's output to help associate the two more easily.
- Updated the default variable_def_regex to include an alphabetic character after a ":" for host variables to avoid false matches with time formats "10:20".
- Improved the variable substitution to also check if a variable is preceeded by a single line comment character.  If so, ignore the match.
        CALL myProc( sl_var1  -- p_var1
                   , sl_var2  -- p_var2
Bug Fixes
- When clearing the results buffer the default register was updated.
- Duplicate tag on MyProjectDir when running helptags (Simon Dambe).
- Some of the variable substitution options Skip, Use Blank had off by one errors.
dbext_1200.zip 12.00 2010-07-15 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- A number of changes around the Oracle formating instructions.  Support for packages when describing certain objects.  These changes were provided by Sergey Khorev.
- Improved the parsing of Perl strings when prompting for variables.
- Made some additional changes to the variable_def_regex for how you can specify it from Vim modelines and DBSetOption.  This makes it much more flexible.
Bug Fixes
- If the word "profile" was used in a dbext profile name dbext would report the error: "dbext: Profiles cannot be nested" (Chris Cierpisz).
- Corrected the regex used to find object owner names (Sergey Khorev).
dbext_1101.zip 11.01 2009-09-08 7.0 Peter Bagyinszki Post by David Fishburn
Bug Fixes
- If a large result set is retrieved, there is a significant performance delay which was introduced in 11.00.  This was related to the new g:dbext_rows_affected feature (Tocer).
- Error E15: Invalid expression: b:dbext_sqlvar_mv[var] is reported if you are using saved variables and then modified the query with a new variable.  Now the saved variables are used for the known variables and you are prompted for the unknown.
dbext_1100.zip 11.00 2009-08-23 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- When autoclose is enabled, a message is displayed indicating autoclose is enabled.  This message will now also include the number of rows affected by the last statement (if applicable).  This is available for all database interfaces which can provide this information.  Vim scripts or mappings have access to this value by referencing the g:dbext_rows_affected variable (Philippe Moravie).
- The Select, Update, Delete, Alter and Drop commands will now complete table names.
- Revamped the saved variables (see |dbext-tutorial-variables|).  dbext checks your queries and will prompt for variables (see |dbext-prompting|).  dbext uses regular expressions to determine which variables should be prompted.  To see how you can easily extend the regular expressions follow the tutorial.  This replaces the previous method which was too limiting.  The new technique uses Vim's standard regular expressions.  This introduces the variable_def_regex dbext option and deprecates the variable_def dbext option.
- With the introduction of saved variables, you are now prompted during SQL execution to determine whether the previously saved variables should be substituted.
Bug Fixes
- If you re-sourced plugin/dbext.vim you would receive the following error: E227: mapping already exists for <Leader>sas
- Errors were reported about undefined variable, dbext_sqlvar_temp_mv,  if executing a SQL statement directly from a filetype which was not SQL (i.e. PHP, Java, csharp, ...).
- If saved variables were in use, it was possible for dbext to used the replaced variables without the user knowing.  For example stored procedures could be created with the replaced strings instead of the variables.
dbext_1000.zip 10.00 2009-03-14 7.0 Peter Bagyinszki Posted by David Fishburn

New Features
- Added new database support for SQL Anywhere UltraLite (11.x).
- Added new database support for Firebird (2.x).
- Added "@@variable" style to the list of bypassed variable names along with IN, OUT, INOUT and DECLARE.
- When listing stored variables, you can now remove multiple lines using visual mode.
- When closing the result window (using "q" or DBResultsClose) you are intentionally returned to the buffer which opened the window instead of allowing Vim to choose which window.
Bug Fixes
- The version 9.00 release of dbext broke modeline support.
- When listing variables the following error could be reported: E121: Undefined variable
- It was not possible to retrieve more than 500 characters from a character or binary column in the database when using DBI or ODBC.  Adding driver_parms=LongReadLen=4096 now works correctly.  You can also change this after you are connected to the database using DBSetOption LongReadLen=4096.  Running DBListConnections will display the current setting for each database connection currently open.
dbext_900.zip 9.0 2009-01-10 7.0 Peter Bagyinszki Posted by David Fishburn
New Features
- Added the ability to set and store SQL variables for each buffer.  This will reduce prompting for statements which are often re-used.  Added support for listing and deleting SQL variables.   Initial prototype by Garrison Yu.
- Added option, g:dbext_default_variable_remember, to control whether SQL variables should be stored when prompted.
- Improved the parsing of SQL statements to account for procedural language.  If a IN, OUT, INOUT or DECLARE statement is found prior to the use of the variable, it is stored for later use.  When the variable is encountered, if the declaration was found we skip prompting for it's value.  This should reduce the number of prompts you receive when executing SQL (i.e. Functions, Procedures, Events, Packages and so on depending on the naming convention you use for your variables.
- Updated the tutorial and added more links to different sections see |dbext-tutorial-variable|
- Added VB filetype support (Garrison Yu).
- Added escaping to allow specifying an new Oracle URL syntax for server connection parameters (Anton Sharonov).
- Renamed DBCloseResults, DBOpenResults, DBRefreshResult, DBToggleResultsResize to DBResultsClose, DBResultsOpen, DBResultsRefresh, DBResultsToggleResize to be more consistent.
Bug Fixes
- You are often repeatedly prompted for connection information.  This change reduces the number and allows you to cancel out of the prompt dialogs.
- Added an unconditional quit command to exit out of Oracle's SQLPlus (Anton Sharonov).
dbext_800.zip 8.00 2008-10-30 7.0 Peter Bagyinszki Posted by David Fishburn
New Features
- When defining a profile or running DBPromptForBufferParameters, you can now optionally specify a file containing commands you want to execute against the database when you first connect (James Horine).
- A new global variable, g:dbext_default_login_script_dir allows you to override the 2 default directories which are searched for these files.
- The dbext tutorial has been updated to demonstrate the login_script.
- Doc update demonstrating the use of integrated logins (Daren Thomas).
- Added a new user defined autocommand dbextPreConnection which is triggered prior to dbext connecting to the database.  This allows you to customize settings based on your buffer and environment (Tim Pope).
Bug Fixes
- Setting LongReadLen for DBI and ODBC connections did not work.
dbext_700.zip 7.00 2008-09-21 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features
- Large change between how the error handling between DBI and ODBC  connections were reported and displayed.
- Non-printable characters are now dealt with for DBI and ODBC connections.
Bug Fixes
- Using ODBC to connect to SQL Server, dbext did not handle informational messages appropriately leading to "not connected" messages (Albie Janse van Rensburg).
- When executing SQL if you were prompted for a variable replacement and cancelled the query the dbext history window was displayed instead of returning to the buffer.
dbext_620.zip 6.20 2008-08-09 7.0 Peter Bagyinszki Posted by David Fishburn
Bug Fixes
- Changed the DB2 TOP X syntax (DBExecSQLTopX).
- Changed the query used to retrieve the current line for DBExecSQLUnderCursor when no text is selected (Sergey Alekhin).
- When parsing a SQL statement for host variables it was possible to miss excluding the INTO clause correctly (Sergey Alekhin).
dbext_610.zip 6.10 2008-06-10 7.0 Peter Bagyinszki Posted by David Fishburn
New Features
- The result window inherits the connection parameters of the buffer which last executed SQL (Antony Scriven).  For example, if you retrieve a list of tables, you may want to describe a table or generate a list of columns for one of the tables.  Using the usual maps will generate the result you need without prompting for connection parameters.  This is especially useful if you have more than 1 buffer and each buffer connects to different databases.
- Added the ability to choose where to put the Result window.  When the window is split you can choose vertical or horizontal, bottom or top, and choose the the width of the window for horizontal switches (Clinton Jones).
- Modified DBExecSQLUnderCursor to select all text until end of line if no valid command terminator is found rather than just one letter (David Venus).
- DBGetOption displays the output from :ver for debugging.
Bug Fixes
- Tutorial update (Nico Coetzee).
- Tutorial update (Clinton Jones).
- DBGetOption reported an exception E730: using List as a String.
dbext_601.zip 6.01 2008-04-29 7.0 Peter Bagyinszki Posted by David Fishburn
Bug Fixes
- On dbext startup an error was reported indicating mapleader was not defined (Matt).
dbext_600.zip 6.00 2008-04-28 6.0 Peter Bagyinszki Posted by David Fishburn

New Features
- dbext now supports table and column names which can contain spaces (Antony Scriven).  There is a corresponding change to sqlcomplete.vim to support this.
- Added an autoclose option.  If you execute SQL which does not return a result set you can choose to have the dbext results window automatically close (unless of course there was an error).  See the autoclose option for more details.
- Added the map shortcuts to each of menu items under the dbext menu so that users can learn them more easily (Alexander Langer).
- Using the menu_mode option you can control if and where the dbext menu is created (Marty Grenfell).  See the menu_mode option for more details.
- For MySQL, added -t as part of the default command line parameters setting.  This will properly format the data into tabs or spaces to make it more readable (Luke Cordingley).
- A message is displayed indicating the time a SQL command began executing.  The result window also contains the time the SQL finished executing.
- DBI or ODBC can now fetch BLOB columns from the database.  By default these are truncated at 500 characters, but that can be changed by issuing: DBSetOption driver_parms=LongReadLen=4096

Bug Fixes
- If a database column had an emdedded double quote this would be displayed as \" in the dbext result window (Jean-Christophe Clavier).
- When loading the plugin, it will now check to ensure the map does not already exist before attempting to create it.  This will prevent errors when mappings clash (Antony Scriven).
- If you prompt for connection parameters using the DBI or ODBC types we need to disconnect any existing connections or the existing connection will continue to be used.
- In some cases when using DBI or ODBC an error was not reported and only a blank result set was returned.  Now the database error is reported back to the user.
- Data retrieved via DBI or ODBC which contained a backslash were not escaped properly and could disappear.
dbext_520.zip 5.20 2007-09-15 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features
- When using DBI or DBI::ODBC null fields are now displayed as NULL instead of empty spaces (now you can distinguish between them).
- When using DBI or DBI::ODBC you can specify the column separator
:let g:dbext_default_dbi_column_delimiter="\t" (Jean-Christophe Clavier)
- When using DBI or DBI::ODBC and you use a vertical orientation for the result set, if there are any embedded newline characters in your data this will be displayed and shifted to align with the column above.  Prior to this all newlines were stripped from the output when printing to preserve standard horizontal output (Jean-Christophe Clavier).
dbext_511.zip 5.11 2007-09-10 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features ------------
- Added support for Oracle Rdb on an Open VMS Node.  
For vim on Open VMS look at http://www.polarhome.com/vim/.
For Open VMS http://h71000.www7.hp.com/openvms/.
Development of Rdb support by Andi Stern
dbext_506.zip 5.06 2007-09-03 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features
- Added Perl's DBI and DBI::ODBC support.  This opens additional database support without having to adjust scripts.  You must have a Perl enabled Vim (:echo has('perl')).  Using the DBI layer offers some advantages over using the native binary tools:
       - Transaction support which allows you to maintain a transaction during your editing session and either commit or rollback and changes.  This is not possible without using the DBI layer.
       - Speed improvements, since the database connection is maintained, the there is less overhead per command.
Huge thanks to Jean-Christophe Clavier and Albie Janse van Rensburg for their beta testing and suggestions.

- New commands are available to select only a few rows instead of an entire result set.  In most databases this is referred to as TOP X.  DBExecSQLTopX, DBExecVisualSQLTopX, DBExecSQLUnderCursorTopX have been added plus associated mappings (Albie Janse van Rensburg).
- Made Cygwin detection a bit easier using the shellslash option (Steve Gibson)
Bug Fixes
- SQL Server support had issues with the queries when running DBCompleteTable, DBCompleteProcedure, DBCompleteView which also affected the sqlcomplete.vim plugin included with Vim7 (Albie Janse van Rensburg).
- Oracle reported "rows will be truncated", added "set linesize 10000" to the Oracle headers (Stuart Brock)
- When prompting for connection parameters if you choose a profile of "0" which is no profile, you had to re-run the wizard to prompt for the rest of the parameters, now the wizard continues as expected.
dbext_420.zip 4.20 2006-12-19 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features
- Improved support for Cygwin.  If you are using a Cygwin compiled Vim (on   Windows) and are accessing Windows compiled binaries (i.e. sqlplus.exe) the binary will complain since it does not understand Unix path names.  Added the option g:dbext_default_use_win32_filenames which allows you to indicate the binaries must use translated Windows paths instead. (Richard)
- DBGetOption displays more information.
Bug Fixes
- SQL Server support had issues with the queries when running DBCompleteTable, DBCompleteProcedure, DBCompleteView which also affected the sqlcomplete.vim plugin included with Vim7 (Albie Janse van Rensburg).
dbext_410.zip 4.10 2006-12-05 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features
- Updated DBGetOption to additionally display a list of all database profiles and their types.  All dbext options that have been overriden via the vimrc are also displayed.
Bug Fixes
- db2 support had issues with the queries when running DBCompleteTable, DBCompleteProcedure, DBCompleteView which also affected the sqlcomplete.vim plugin included with Vim7 (Peter Princz).
- The documentation was still indicating there was a plugin dependency which has been removed with Vim7.
dbext_400.zip 4.03 2006-09-23 7.0 Peter Bagyinszki Posted by David Fishburn.
New Features
- dbext.vim now requires Vim7.
- dbext.vim no longer has dependencies on other plugins by utilizing the new Vim7 features (Lists and Dictionaries).
- When using the DBCompleteTable, DBCompleteProcedure, DBCompleteView commands errors are displayed instead of silently ignored.  This makes them more useful with the sqlComplete plugin (see |sql.txt|).
- Added new option, dbext_default_MYSQL_version, for MySQL to indicate the version you using.
- You can optionally define a function, DBextPostResult, in your .vimrc, this function will be called each time the result window is updated.  This function can be used to do anything, for example, syntax highlighting the result set in the result window.

Bug Fixes
- Added version support with MySQL to control what SQL is sent for version 4 and 5 servers.
dbext_350.zip 3.50 2006-06-20 6.0 Peter Bagyinszki New Features
- g:dbext_default_inputdialog_cancel_support = 0 will prevent inputdialog from providing a cancel option.  This works around a Vim7 bug.  dbext will automatically detect this and set the option the first time it is encountered.
- Changed the order of some of the text in the dialog boxes to make them more readable when using the console version of Vim.
- dbext can parse SQL statements and prompt the user to replace variables with values prior to sending the statement to the database to be executed.  This is useful for testing SQL which is embedded in your code without having to manually replace variables and string concatentation.  A new identifier (the until flag) allows you to specify the beginning of a string and what to prompt for until a finishing string.  This makes it more flexible for you to configure what you would like prompting for when looking for variables.

Bug Fixes
- DBPromptForBufferParameters can report "E180: Invalid complete value: -1" if running the console version of Vim.  dbext will detect this problem and automatically set g:dbext_default_inputdialog_cancel_support = 0 to work around this Vim7 bug.

dbext_300.zip 3.00 2006-05-15 6.0 Peter Bagyinszki New Features
- dbext supports a history of previous commands.  The DBHistory command will display a numbered list of previous SQL statements.  Pressing <enter> or double clicking on one of the items will execute the statement.  The number of items in the list is configurable via your vimrc.  The history items are stored in a file, dbext_sql_history.txt.  The location of the file can also be controlled.
- The 'refresh' feature added in version 2.30 has been updated to take advantage of the history feature.
- The PHP parser has improved and can handle single or double quoted strings, string concatenation and host variables.  It will correctly strip the quotes, join the concatenated strings and prompt the user for host variables before executing the SQL statement.
- Updated documentation for Vim 7 SQL code completion.
- Table, procedure and view dictionaries include the owner name of the object.  This is on by default, but can be controlled via a new global option, dbext_default_dict_show_owner.  This has not been enabled for all databases it depends on whether the database supports this feature.  The autoload\sqlcomplete.vim plugin takes advantage of this feature.
- Added support for stored procedures / functions in MySQL 5.
Bug Fixes
- Updated the PHP parser to work with a more varied string quotes and string concatenation.
- The "extra" feature did not add a leading space for MySQL.  Using the tabbed output required updates to the parsing of the output generated by MySQL.
- Miscellaneous documentation updates.
dbext_230.zip 2.30 2005-09-13 6.0 Peter Bagyinszki New Features
- The result window has a local buffer mapping 'R', which will 'refresh' the window.  This means it will re-run the previous statement which is useful if you are repeatedly checking something in the database.
- SQL Anywhere (ASA) no longer relies on the jcatalogue tables to be installed in the database.  System views are used instead.
- Support for MySQL 5.0 has been added, which includes stored procedures and views (as much as the beta allowed).
- For Postgress SQL you can now optionally enter an owner name to filter by when showing list of objects (tables, procedures, views).

Bug Fixes
- The alternate-file is no longer changed the first time the result buffer is opened.
- Using DB2 with db2cmd incorrectly specified the command terminator with td, instead of -t.
- On win32 platforms, if the bin_path has been specified for DB2, then add this to the system path since db2cmd relies on other batch files to operate correctly.
- The connection string is displayed by both the Result buffer (first line) and the titlestring to the buffer (if enabled).  This was not correctly appending the user used to connect to the database.
- When parsing Vim scripts we did not correctly remove a leading line continuation slash from the from of a query.
dbext_220.zip 2.20 2005-03-10 6.0 Peter Bagyinszki New Features
- Added new connection parameter called "extra", you can place any
additional command line parameters in this option.
- DBGetOption displays all options including the dbext version.
- Better support for command terminators that have newline or special
characters in them.  For example ASE/SQLSRV use "\ngo\n", now the command
DBExecSQLUnderCursor will correctly find the statement.
- Use_tbl_alias defaults to "ask", instead of "default on".
- For most supported databases, when displaying the Table / Procedure /
View List, you can now enter a partial string "DBA.", and if a . is included
it will only display objects created / owned by that userid.
- DBExecSQLUnderCursor would sometimes stop in the middle of a query if the
command terminator was included (inside a quoted string), now it ensures
there is no text following the terminator.
- The result window also includes the error code returned by the binary
used to execute the command.  This can be useful for debugging.
- The first line of the result window includes a line showing the
connection information, if you have many buffers open, it can be difficult
to determine which database you are executing commands against.  A glance at
this line will tell you immediately.
- g:dbext_default_always_prompt_for_variables = 0 will prevent you from
being prompted for substitution parameters.  Setting this value to 1 will
always prompt the user.
- You can now abort the execution of a statement if you are prompted for
substitution parameters.
- If you are prompted for parameters, if you choose "Stop Prompting" the
command will be executed immediate.  If "Never Prompt" is chosen, no further
prompting will occur for this buffer.

Bug Fixes
- SQLSRV did not have a default command terminator, now it is "\ngo\n".
- Changed the Oracle command terminator to ";", and the routine that
executes the statements automatically adds the "\nquit;\n" so that   sqlplus
will complete.
- Spaces were not correctly removed from column lists in all cases, this
showed up as an issue with the SQL Intellisense plugin.
- When executing SELECT statements the INTO clause (if present) is removed
so the results are displayed in the result window.  Refined the removal of
the INTO clause to ensure it does not interfer with an INSERT or MERGE
dbext_211.zip 2.11 2004-09-24 6.0 Peter Bagyinszki Bug fix: On some platforms the temporary file created to execute SQL
statements must end in ".sql".  Corrected this for all databases.
dbext_210.zip 2.10 2004-09-15 6.0 Peter Bagyinszki New Features
- Support for the SQLite database has been added (thanks to Ron Aaron).
dbext-2.01.zip 2.01 2004-07-22 6.0 Peter Bagyinszki New Features
- Tutorial - Based on feedback from users, created a step by step tutorial.
All users should try the tutorial to learn how to use the various features
of the plugin.
- DBGetOption - without parameters populates the Result window with all
- DBGetOption and DBSetOption support command line completion for the
various options (DBGetOption d<tab>, will cycle through all options
beginning with "d").
- New option, replace_title, changes the title of the buffer to show
connection information which is useful if you are using  a scratch buffer to
test SQL.
- IntegratedLogin support for Windows users.
- DBExecRangeSQL - useful for custom mappings, and executing commands
without visual mode.
- New maps <Leader>sea - sql - execute - all (lines in the file),
<Leader>sel - sql - execute - line (the current line)
- New filetype support - jproperties

Bug Fixes
- dbname was not defaulting correctly.
- bin_path did not work correctly on windows platforms.
- Updated the connection text in the Result buffer.
- Overhauled the DB2 support.
dbext-2.0.zip 2.00 2004-07-11 6.0 Peter Bagyinszki dbext.vim has been greatly enhanced for version 2.00.

Additional features include:

Connection Profiles
You can create as many profiles as you like in your vimrc.  Each profile specifies various connection information.  When you are prompted for connection information, for ease of use,  you can choose from a numbered list.

Modeline Support
Similar to Vim modelines, you can specify connection information as comments within your buffers.  To prevent sensitive information (ie passwords) from being visible, you can specify a connection profile as part of your modeline.  

Object Completion
dbext ties into Vim dictionary feature.  You can complete table names, procedure names and view names.

Viewing Lists of Objects
You can browse through the various objects in the database you are connected
to and specify wildcard information.  For example you can say, "Show me all
tables beginning with 'ml_' ".  These objects are currently supported:
Tables, Procedures, Views,  Columns (for a table).

FileType Support Added
dbext has support for various filetypes.  For example, assume you dynamically build a SQL statement by joining strings together, using calls to functions, host parameters.  By visually selecting the code and executing it dbext will parse the statement, strip out the various string joining commands (+, ||,  .) and prompt you for host values before sending the string to be executed against the database.  This way it is very easy to test your SQL statements without having to cut and paste the commands into a SQL tool.  Currently supported filetypes are: PHP, Java, JSP, JavaScript, Perl, SQL, Vim.

Intellisense Addin Support
The Intellisense  plugin now has SQL supported.  To enable greater functionality (table, procedure, view lists), it uses dbext.vim to retrieve this information.
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.