Thomas Zhang的杂货铺
19 05, 2008
Windows下采用处理spool数据并用WinRAR压缩的一个DEMO
作者 tomszrp 18:55 | Permalink 静态链接网址 | Comments 最新回复 (3) | Trackback 引用 (0) | 磨刀石

源至一个puber的需求:要spool一些数据出来,并自动实现压缩功能

要实现这个目的,需要具备如下几个条件
1)安装并配置了WinRAR,设置相应的path,否则可能遇到找不到Rar.exe文件的错误
比如:set PATH=%PATH%;C:Program FilesWinRAR
2)编写实现spool 数据的SQL脚本,比如
mysql.sql内容类似如下:
spool e:test.txt
select sysdate from dual;
spool off
exit
#具体的SQL内容要根据自己的需要做相应的调整
3)编写bat文件,比如mybat.bat
内容类似如下:
sqlplus study/study@ora10g @e:mysql.sql
Rar a e:my.rar e:test.txt
del e:test.txt

#具体的bat内容根据实际的实际情况做相应的调整

最后就可以调用mybat.bat达到自己的目的了,测试如下:

E:>set PATH=%PATH%;C:Program FilesWinRAR

E:>mybat.bat

E:>sqlplus study/study@ora10g @e:mysql.sql

SQL*Plus: Release 10.2.0.2.0 - Production on Mon May 19 18:40:48 2008

Copyright (c) 1982, 2005, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options


SYSDATE
------------
19-MAY-08

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Pr
oduction
With the Partitioning, OLAP and Data Mining options

E:>Rar a e:my.rar e:test.txt

RAR 3.71 版权 (C) 1993-2007 Alexander Roshal 20 九月 2007
共享版本 输入 RAR -? 获得帮助

评估版本,请注册

正在创建 压缩文件 e:my.rar

正在添加 e:test.txt 完成
完成

E:>del e:test.txt

E:>dir my.rar
驱动器 E 中的卷是 工作盘
卷的序列号是 3C1B-44A4

E: 的目录

2008-05-19 18:40 125 my.rar
1 个文件 125 字节
0 个目录 30,395,387,904 可用字节

E:>


Comments

Okay,good idea! i'll go back jinan on Dragon Boat Festival

作者 thomas zhang 21 05 2008, 10:14

rp,工作是别人的,心情是自己的,回来和zmq找你吃饭如何?

作者 tony_lyl 21 05 2008, 09:18

有空一起吃饭?

作者 tony_lyl 21 05 2008, 09:07
发表评论
标题:


称呼:


邮箱地址(可选):


个人主页(可选):


发表评论:
Bold Italic Link authimage




博客日历
« 七月 2008 »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
搜索
最新发表
文章分类
文章归档
网站链接
新闻聚合