- 论坛徽章:
- 0
|
谢谢,可以实现更新时间,但是有点小问题,麻烦再帮看下。
参数文件: /amphome/mezong/ParamFiles/param_P63B_GIM_Aggregator_IssuerForScript.prm
################ PARAMETER FILE FOR P63B GIM ################
[Global]
$DBConnection_GSSM=GSSM_E1
$$EXTRACT_TYPE=ISSUER
$$START_TSTP=13-JAN-12 14:00:00
$$END_TSTP=13-JUN-12 14:19:00
$$VER_NUM=4.0
$$MSG_TYPE=FULL
$$MSG_LOV=
$$INSTR_TYPE_LIST=
$Param_EXTRACT_QUERY=SELECT NULL AS INSTR_TYP_CD,a.INSTR_ISSUER_ID || '||' || Greatest(a.efct_tstp,NVL(b.efct_tstp,a.efct_tstp),NVL(c.efct_tstp,a.efct_tstp)) ||'|Issuer|FinInstIds|' || a.INSTR_ISSUER_ID_XML_OBJ || '|Issuer|Indicative|' || b.INSTR_ISSUER_IND_XML_OBJ || '|Issuer|Analytics|' || c.INSTR_ISSUER_ANLY_XML_OBJ || '|ISSUER|' AS XML_OBJECT FROM (SELECT * FROM SMEXTN01.INSTR_ISSUER WHERE EFCT_TSTP <> EXPR_TSTP ) a LEFT JOIN (SELECT * FROM SMEXTN01.INSTR_ISSUER_IND WHERE EFCT_TSTP <> EXPR_TSTP ) b ON a.INSTR_ISSUER_ID = b.INSTR_ISSUER_ID AND a.INSTR_ISSUER_VRSN_NBR = b.INSTR_ISSUER_VRSN_NBR LEFT JOIN (SELECT * FROM SMEXTN01.INSTR_ISSUER_ANLY WHERE EFCT_TSTP <> EXPR_TSTP ) c ON a.INSTR_ISSUER_ID = c.INSTR_ISSUER_ID AND a.INSTR_ISSUER_VRSN_NBR = c.INSTR_ISSUER_VRSN_NBR WHERE a.efct_tstp BETWEEN to_timestamp('$$START_TSTP','DD-MON-YY HH24:MI:SS') AND to_timestamp('$$END_TSTP','DD-MON-YY HH24:MI:SS') OR b.efct_tstp BETWEEN to_timestamp('$$START_TSTP','DD-MON-YY HH24:MI:SS') AND to_timestamp('$$END_TSTP','DD-MON-YY HH24:MI:SS') OR c.efct_tstp BETWEEN to_timestamp('$$START_TSTP','DD-MON-YY HH24:MI:SS') AND to_timestamp('$$END_TSTP','DD-MON-YY HH24:MI:SS')
脚本如下:
#!/bin/bash
#!/bin/sh
PARA=/amphome/mezong/ParamFiles/param_P63B_GIM_Aggregator_IssuerForScript.prm
# Get start time
START_TSTP=`grep '$$END_TSTP=' $PARA | cut -d"=" -f2`
# Put your ETL command here.
# Get end time
END_TSTP=`date '+%d-%b-%y %H:%M:%S'`
# update start and end time in Param.prm file
awk -v s="$START_TSTP" -v e="$END_TSTP" '/START_TSTP/{$2=s}/END_TSTP/{$2=e}1' FS="=" OFS="=" $PARA > temp.file
mv temp.file $PARA
echo "The application run from $START_TSTP and stopped at $END_TSTP"
运行完的结果是 时间更新了,但是参数文件里面的 $Param_EXTRACT_QUERY 部分也被替换了。请看运行完后的参数文件:
################ PARAMETER FILE FOR P63B GIM ################
[Global]
$DBConnection_GSSM=GSSM_E1
$$EXTRACT_TYPE=ISSUER
$$START_TSTP=13-JUN-12 14:19:00
$$END_TSTP=20-Jun-12 01:55:12
$$VER_NUM=4.0
$$MSG_TYPE=FULL
$$MSG_LOV=
$$INSTR_TYPE_LIST=
$Param_EXTRACT_QUERY=20-Jun-12 01:55:12= b.INSTR_ISSUER_ID AND a.INSTR_ISSUER_VRSN_NBR = b.INSTR_ISSUER_VRSN_NBR LEFT JOIN (SELECT * FROM SMEXTN01.INSTR_ISSUER_ANLY WHERE EFCT_TSTP <> EXPR_TSTP ) c ON a.INSTR_ISSUER_ID = c.INSTR_ISSUER_ID AND a.INSTR_ISSUER_VRSN_NBR = c.INSTR_ISSUER_VRSN_NBR WHERE a.efct_tstp BETWEEN to_timestamp('$$START_TSTP','DD-MON-YY HH24:MI:SS') AND to_timestamp('$$END_TSTP','DD-MON-YY HH24:MI:SS') OR b.efct_tstp BETWEEN to_timestamp('$$START_TSTP','DD-MON-YY HH24:MI:SS') AND to_timestamp('$$END_TSTP','DD-MON-YY HH24:MI:SS') OR c.efct_tstp BETWEEN to_timestamp('$$START_TSTP','DD-MON-YY HH24:MI:SS') AND to_timestamp('$$END_TSTP','DD-MON-YY HH24:MI:SS')
我们参数文件里面其他的参数值不能替换的,我们ETL需要调用时间更新后的这个参数文件。 |
|