Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for vimconfig/vim/modules/database-client.vim between version 1.3 and 1.4

version 1.3, 2004/02/23 17:52:54 version 1.4, 2004/02/24 07:43:02
Line 2 
Line 2 
 "  "
 " File:                 database-client.vim  " File:                 database-client.vim
 " Maintainer:   Lubomir Host 'rajo' <rajo AT platon.sk>  " Maintainer:   Lubomir Host 'rajo' <rajo AT platon.sk>
 " Version:              $Platon: vimconfig/vim/modules/database-client.vim,v 1.2 2004/02/18 07:59:48 rajo Exp $  " Version:              $Platon: vimconfig/vim/modules/database-client.vim,v 1.3 2004/02/23 17:52:54 rajo Exp $
 "  "
 " Copyright (c) 2003 Platon SDG, http://platon.sk/  " Copyright (c) 2003 Platon SDG, http://platon.sk/
 " Licensed under terms of GNU General Public License.  " Licensed under terms of GNU General Public License.
 " All rights reserved.  " All rights reserved.
 "  "
 " $Platon: vimconfig/vim/modules/database-client.vim,v 1.2 2004/02/18 07:59:48 rajo Exp $  " $Platon: vimconfig/vim/modules/database-client.vim,v 1.3 2004/02/23 17:52:54 rajo Exp $
 "  "
   
 " This plugin needs Perl interpreter to be enabled (+perl feature)  " This plugin needs Perl interpreter to be enabled (+perl feature)
Line 44  endif
Line 44  endif
   
 " Control whether additional help is displayed as part of the taglist or not.  " Control whether additional help is displayed as part of the taglist or not.
 " Also, controls whether empty lines are used to separate the tag tree.  " Also, controls whether empty lines are used to separate the tag tree.
 if !exists('SQL_Compact_Format')  if !exists('g:SQL_Compact_Format')
     let SQL_Compact_Format = 0      let g:SQL_Compact_Format = 0
   endif
   
   
   " Default SQL command on startup
   if !exists('g:SQL_last_command')
       let g:SQL_last_command = "SELECT * FROM table"
 endif  endif
   
 "---------------------------------------------------------------------------  "---------------------------------------------------------------------------
Line 123  perl << EOF
Line 129  perl << EOF
   
         } # }}}          } # }}}
   
           package main;
   
           # number of executed SQL commands
           my $sql_cmd_num = 0;
   
 EOF  EOF
 endfunction  endfunction
 " }}}  " }}}
Line 272  EOF
Line 283  EOF
 endfunction  endfunction
 " }}}  " }}}
   
   " get SQL command from user and execute
   function! SQL_Execute() " {{{
   
           let sql_cmd = inputdialog('SQL command:', g:SQL_last_command)
           if sql_cmd != ''
                   call SQL_Do(sql_cmd)
           endif
           unlet sql_cmd
   
   endfunction
   " }}}
   
   
 " execute SQL command  " execute SQL command
 function! SQL_Do(sql_cmd) " {{{  function! SQL_Do(sql_cmd) " {{{
   
           " get number of SQL cmd window
           let cmd_winnum  = bufwinnr(g:SQL_cmd_window_title)
   
         perl << EOF          perl << EOF
         use DBI;          use DBI;
   
Line 283  function! SQL_Do(sql_cmd) " {{{
Line 310  function! SQL_Do(sql_cmd) " {{{
         my $dbh = $main::connections->{$main::current_conn}->{dbh};          my $dbh = $main::connections->{$main::current_conn}->{dbh};
         my $sql_cmd = VIM::Eval("a:sql_cmd"); # get function parameter from Vim to Perl          my $sql_cmd = VIM::Eval("a:sql_cmd"); # get function parameter from Vim to Perl
   
           # remove empty chars from beginning and end of string
           # add semilon at the end
           $sql_cmd =~ s/^\s+//g;
           $sql_cmd =~ s/;?\s*$/;/g;
   
           # remember last SQL command
           VIM::DoCommand('let g:SQL_last_command="' . $sql_cmd . '"');
   
           $main::sql_cmd_num++;
           my $winnr = VIM::Eval("cmd_winnum");
           my ($window) = VIM::Windows($winnr);
           my $cmd_buf = $window->Buffer();
           my $last_line = $cmd_buf->Count(); # number of lines
   
           # add SQL cmd separator
           $cmd_buf->Append($last_line, "-- Commnad #$main::sql_cmd_num: " . scalar localtime, $sql_cmd, "");
   
         my $sth = $dbh->prepare($sql_cmd) or warn $DBI::errstr;          my $sth = $dbh->prepare($sql_cmd) or warn $DBI::errstr;
         $sth->execute();          $sth->execute();
         $sth->dump_data();          $sth->dump_data();
   
           undef $window;
           undef $cmd_buf;
           undef $last_line;
           undef $winnr;
   
 EOF  EOF
   
           unlet cmd_winnum
   
 endfunction  endfunction
 " }}}  " }}}
   
Line 299  function! CreateMenu() " {{{
Line 350  function! CreateMenu() " {{{
         silent! aunmenu SQL          silent! aunmenu SQL
         amenu 200.10 S&QL.&Connect :call SQL_Connect()<Return>          amenu 200.10 S&QL.&Connect :call SQL_Connect()<Return>
         amenu 200.20 S&QL.&Disconnect :call SQL_Disconnect()<Return>          amenu 200.20 S&QL.&Disconnect :call SQL_Disconnect()<Return>
         amenu 200.30.5  S&QL.&Show.&connections :call SQL_ShowConnections()<Return>          amenu 200.30 S&QL.&Execute :call SQL_Execute()<Return>
         amenu 200.30.10 S&QL.&Show.&databases :call SQL_Do('SHOW DATABASES')<Return>          amenu 200.40.10 S&QL.&Show.&connections :call SQL_ShowConnections()<Return>
         amenu 200.30.20 S&QL.&Show.&tables :call SQL_Do('SHOW TABLES')<Return>          amenu 200.40.20 S&QL.&Show.&databases :call SQL_Do('SHOW DATABASES')<Return>
         amenu 200.30.30 S&QL.&Show.&variables :call SQL_Do('SHOW VARIABLES')<Return>          amenu 200.40.30 S&QL.&Show.&tables :call SQL_Do('SHOW TABLES')<Return>
         amenu 200.30.40 S&QL.&Show.&server\ status :call SQL_Do('SHOW STATUS')<Return>          amenu 200.40.40 S&QL.&Show.&variables :call SQL_Do('SHOW VARIABLES')<Return>
           amenu 200.40.50 S&QL.&Show.&server\ status :call SQL_Do('SHOW STATUS')<Return>
           amenu 200.50.10 S&QL.&Windows.&create :call CreateWindows()<Return>
 endfunction  endfunction
 " }}}  " }}}
 call CreateMenu()  call CreateMenu()
Line 312  function! s:CloseWindow(winnum) " {{{
Line 365  function! s:CloseWindow(winnum) " {{{
         " if window exists          " if window exists
         if a:winnum >= 0          if a:winnum >= 0
                 execute "normal \<c-w>" . a:winnum . "w"                  execute "normal \<c-w>" . a:winnum . "w"
                 close                  silent! close
         endif          endif
 endfunction  endfunction
 " }}}  " }}}
Line 320  endfunction
Line 373  endfunction
 " create windows  " create windows
 function! CreateWindows() " {{{  function! CreateWindows() " {{{
         let s:main_winnum = bufwinnr(g:SQL_main_window_title)          let s:main_winnum = bufwinnr(g:SQL_main_window_title)
         let s:data_winnum = bufwinnr(g:SQL_data_window_title)  
         let s:cmd_winnum  = bufwinnr(g:SQL_cmd_window_title)  
   
         call s:CloseWindow(s:main_winnum)          call s:CloseWindow(s:main_winnum)
   
           let s:data_winnum = bufwinnr(g:SQL_data_window_title)
         call s:CloseWindow(s:data_winnum)          call s:CloseWindow(s:data_winnum)
   
           let s:cmd_winnum  = bufwinnr(g:SQL_cmd_window_title)
         call s:CloseWindow(s:cmd_winnum)          call s:CloseWindow(s:cmd_winnum)
   
         execute 'topleft split ' . g:SQL_cmd_window_title          execute 'topleft split ' . g:SQL_cmd_window_title

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top