bat文件中能否调用创建存储过程的sql语句

[复制链接]
查看11 | 回复3 | 2017-4-29 10:55:21 | 显示全部楼层 |阅读模式
我创建了一个a.bat 文件,文件内容如下:
@echo off
echo
db2cmd db2 -tf"sql.txt"同一文件目录下的 sql.txt文件内容如下:
connect to ***db user *****using *****;
update sp_ipc set ******* where ******;
call update_ipc();
call update_iteminfo();
delete from ****where *******;
delete from **** where ******;
call update_nsn();
connect reset;
直接运行a.bat,OK!
接下来想将创建这几个存储过程也放到批处理里面去,创建一个 update_ipc.txt,内容如下:
connect to ***db user *****using *****;
drop update_ipc();
CREATE PROCEDURE update_ipc() P1: BEGIN DECLARE v_at_end , v_counter INTEGER DEFAULT 0;**************; END P1
connect reset;
修改a.bat 文件,在echo下增加一行 db2cmd db2 -tf"update_ipc.txt",运行a.bat ,出错。
向大虾求教,创建存储过程的语句能放在bat文件里面执行吗?如果可以,bat文件该怎么写?

回复

使用道具 举报

千问 | 2017-4-29 10:55:21 | 显示全部楼层
-t 默认是以;作为分割符,但在存储过程中肯定会有;
可以考虑将语句的分割符设置为其他字符,然后执行的时候指定分割符,如换为以@作为分割符:
db2 -td@ -f filename
回复

使用道具 举报

千问 | 2017-4-29 10:55:21 | 显示全部楼层
按照2楼的方法试一下。
回复

使用道具 举报

千问 | 2017-4-29 10:55:21 | 显示全部楼层
3833020 发表于 2013-8-9 20:04
-t 默认是以;作为分割符,但在存储过程中肯定会有;
可以考虑将语句的分割符设置为其他字符,然后执行的时候 ...

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行