drop table testBat;
create table testBat(
batchid varchar2(16),
first_date date,
machine varchar(30)
);
create or replace function FTESTBAT(p_batchid varchar2,p_first_date varchar2,p_machine varchar2)
return number as
v_date date;
begin
v_date:=to_date(p_first_date,'yyyy-mm-dd hh24:mi:ss');
insert into testBat(Batchid, First_Date,Machine) values(p_batchid,v_date,p_machine);
commit;
return 0;
end;
declare
v_result number;
begin
v_result := FTESTBAT('&1','&2','&3');
dbms_output.put_line(v_result);
end;
/
@echo off
rem 获取当前时间作为批次号
if "%time:~0,1%"==" " (set curr_time=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%) else (set curr_time=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%ti me:~6,2%)
echo %curr_time%
echo %1
rem 获取主机名
echo computername=%computername%
rem 指定时间
set restart_time=08:00:00
set restart=%date:~0,4%-%date:~5,2%-%date:~8,2% %restart_time%
echo %restart%
rem 调用函数的第三个参数需要根据不同主机进行调整
sqlplus linml/123456@JBITDB @insert.sql '%curr_time%' "%restart%" "%computername%"
set heading off
set pagesize 0;
set feedback off;
set verify off;
set echo off;
select 'str:'||DBAH.FGET_CALL_IDS from dual;
exit
@echo off
set result=c:\test\result_2017.txt
set tmp_file=c:\test\tmp_file.txt
set out=c:\test\out.log
set phonefile=c:\test\phonefile.txt
sqlplus test/***@TEST @check_call_function.sql > %result%
If errorlevel 1 (
Echo get error!
) Else (
Echo get success!
)
格式:%date:~x,y%以及%time:~x,y%
说明:x是开始位置,y是取得字符数
echo %date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
注意:上述写法造成的问题是当小于10点时,日期与时间之间会出现一个空格为避免出现这种情况,可以在外层增加一个判断语句
bat批处理 if 命令示例详解_DOS/BAT_脚本之家 http://www.jb51.net/article/14986.htm