欢迎投稿

今日深度:

[20190920]完善vim调用sqlplus脚本.txt,sql如何调用存储过程

[20190920]完善vim调用sqlplus脚本.txt,sql如何调用存储过程


[20190920]完善vim调用sqlplus脚本.txt

--//以前写的http://blog.itpub.net/267265/viewspace-2140936/=>[20170617]vim中调用sqlplus.txt
--//本来自己想写一个转化oracle 数字的脚本,对于我来讲难度有点大。使用utl_raw.cast_to_number函数相对简单,缺点就是有
--//数据库可供使用。

$ cat sql.vim
" oracle
noremap  <Leader>q1 Yp!!sqlplus -s scott/btbtms@test01p @D:\tools\Vim\vim80\o.txt<CR>kISCOTT@test01p><space>
noremap  <Leader>q2 Yp!!sqlplus -s sys/btbtms@test01p as sysdba @D:\tools\Vim\vim80\o.txt<CR>kISYS@book><space>

noremap  <Leader>q3 Yp!!sqlplus -s scott/btbtms@test01p @D:\tools\Vim\vim80\o.txt<CR>
noremap  <Leader>q4 Yp!!sqlplus -s sys/btbtms@test01p as sysdba @D:\tools\Vim\vim80\o.txt<CR>
noremap  <Leader>q5 Yp:s/ //eg<CR>Iselect utl_raw.cast_to_number(lower('<ESC>A')) n20 from dual;<ESC>!!sqlplus -s scott/btbtms@test01p<CR>

vnoremap  ;q3       "ay<ESC>gv!sqlplus -s scott/btbtms@test01p @D:\tools\Vim\vim80\o.txt<CR>
vnoremap  ;q4       "by<ESC>gv!sqlplus -s sys/btbtms@test01p as sysdba @D:\tools\Vim\vim80\o.txt<CR>

--//在sqlplus下使用如下脚本转化raw到numbere.
$ cat conv_n.sql
select utl_raw.cast_to_number(lower('&1')) n20 from dual;

--//o.txt内容主要定义列宽度,主要12c许多字段都是128.如果不设定宽度,显示效果很差.
--//可以参考http://blog.itpub.net/267265/viewspace-2140939/=>[20170618]12c 支持更长的 identifiers

--//脚本缺点就是用户与口令写死了,根据需要修改就ok了。
--//再次提醒注意一点执行的语句最好不要是dml语句,比如insert,update,delete语句,还有truncate语句.因为缺省就是退出就是
--//commit.存在一定的风险.
--//执行select语句一般问题不大.作为测试学习也应该避免dml语句,不然把这种习惯带到生产库出问题就麻烦了.
--//补充1点,还可以适当设置大一点linesize,这样避免出现折行情况.当然还有致命的缺点,每次执行都要打开与关闭数据库的连接.而且
--//连接串是写死的.

--//有机会自己写代码实现\q5的功能.测试如下:
c10203  
--//快速按\a5,输出如下:

       N20
----------
      1.02

www.htsjk.Com true http://www.htsjk.com/oracle/36418.html NewsArticle [20190920]完善vim调用sqlplus脚本.txt,sql如何调用存储过程 [20190920]完善vim调用sqlplus脚本.txt --//以前写的http://blog.itpub.net/267265/viewspace-2140936/=[20170617]vim中调用sqlplus.txt --//本来自己想写一个...
相关文章
    暂无相关文章
评论暂时关闭