标题: [文件操作] 求助排错批处理for语句输出多条sql命令语句报错“此时不应有……” [打印本页]
作者: paopaomm 时间: 2016-8-16 19:18 标题: 求助排错批处理for语句输出多条sql命令语句报错“此时不应有……”
本帖最后由 pcl_test 于 2016-8-16 20:08 编辑
- @echo off
- rem =======================================================================
- rem = 本批处理实现目录数据同步到中心 ---20160816 =
- rem =======================================================================
- set DumpFolder=d:\dmp
- set LogFolder=d:\log
- set FileDate=%Date:~0,4%%Date:~5,2%%Date:~8,2%
- set UserName=datacenter
- set Password=datacenter
- set NetServer=orcl
- for /f "tokens=1 delims=_" %%i in ('dir /a-d /b *.dmp') do (
- echo insert into rc_catalog_basic_bak select * from rc_catalog_basic where ORGANIZATION_ID = '%%i';>%DumpFolder%\pre.sql
- echo insert into rc_resource_info_bak select * from rc_resource_info t where (t.catalog_resource_id,t.version) in (select catalog_resource_id,version from rc_catalog_basic where ORGANIZATION_ID = '%%i');>>%DumpFolder%\pre.sql
- echo insert into rc_dynamic_authority_bak select * from rc_dynamic_authority t where (t.catalog_resource_id,t.version) in (select catalog_resource_id,version from rc_catalog_basic where ORGANIZATION_ID = '%%i');>>%DumpFolder%\pre.sql
- echo commit;>>%DumpFolder%\pre.sql
- echo delete from rc_catalog_basic where ORGANIZATION_ID = '%%i';>>%DumpFolder%\pre.sql
- echo delete from rc_resource_info t where (t.catalog_resource_id,t.version) in (select catalog_resource_id,version from rc_catalog_basic where ORGANIZATION_ID = '%%i');>>%DumpFolder%\pre.sql
- echo delete from rc_dynamic_authority t where (t.catalog_resource_id,t.version) in (select catalog_resource_id,version from rc_catalog_basic where ORGANIZATION_ID = '%%i');>>%DumpFolder%\pre.sql
- echo commit;>>%DumpFolder%\pre.sql
- echo 前置机%%i数据环境初始化开始。。。
- start /b /wait sqlplus %UserName%/%Password%@%NetServer% @%DumpFolder%\pre.sql >%LogFolder%\%%i_%Date:~0,4%%Date:~5,2%%Date:~8,2%.log
- echo 前置机%%i数据环境初始化完毕!
- )
- pause
复制代码
下面这个就没事,奇怪死了==- @echo off
- echo insert into rc_catalog_basic_bak select * from rc_catalog_basic where ORGANIZATION_ID = '%%i';>pre.sql
- echo insert into rc_resource_info_bak select * from rc_resource_info t where (t.catalog_resource_id,t.version) in (select catalog_resource_id,version from rc_catalog_basic where ORGANIZATION_ID = '%%i');>>pre.sql
- pause
复制代码
谢谢大神的帮助~~~~~
作者: dreamer 时间: 2016-8-16 19:33
本帖最后由 dreamer 于 2016-8-16 19:36 编辑
我覺得是sql 語法的() 問題,將() 換成^( ^)試試
補充:
已測試,替換後可執行
作者: xxpinqz 时间: 2016-8-16 19:42
13-18行的 ) 改为 ^)
作者: pcl_test 时间: 2016-8-16 20:19
cmd语法检测比较粗略,对于嵌套的括弧不能很好的识别匹配
语法上do (与就近的where (t.catalog_resource_id,t.version)识别为成对括弧,提前闭合语句了
作者: jains521 时间: 2016-8-17 18:44
还是sql...
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |