我在Pentaho Kettle的输入步骤中运行以下代码:
SELECT * FROM ${TABELA} WHERE TS_SAMPLETM BETWEEN TO_DATE('${HOJE}', 'DD/MM/YYYY') AND TO_DATE('${SEMANAPASSADA}','DD/MM/YYYY')
但是,当我通过这个shell脚本运行Job时:
#!/bin/sh
cd /home/rafael/data-integration/
export HOJE=$(date +"%d/%m/%Y")
export SEMANAPASSADA=$(date -d "7 days ago" +"%d/%m/%Y")
export tabela=tabela1
sh kitchen.sh -file=/home/rafael/data-integration/Job_Oracle_MySql.kjb -param:TABELA=$TABELA -param:HOJE=$HOJE -param:SEMANAPASSADA=$SEMANAPASSADA
表输入步骤不会替换变量。
答案 0 :(得分:1)
您的问题是shell脚本中的错误,而不是Pentaho或Table Input Step的错误。如果您尝试在最后一行的echo
之前插入sh
,则可以看到运行的命令:
echo sh kitchen.sh -file=/home/rafael/data-integration/Job_Oracle_MySql.kjb -param:TABELA=$TABELA -param:HOJE=$HOJE -param:SEMANAPASSADA=$SEMANAPASSADA
对我来说这是输出:
sh kitchen.sh -file = / home / rafael / data-integration / Job_Oracle_MySql.kjb -param:TABELA = -param:HOJE = 18/12/2015 -param:SEMANAPASSADA =
你的shellcript中的问题是
$TABELA
替换为$tablea
export SEMANAPASSADA=$(date -v -7d +"%d/%m/%Y")
在我运行脚本后进行这些更改后,它会输出:
sh kitchen.sh -file = / home / rafael / data-integration / Job_Oracle_MySql.kjb -param:TABELA = tabela1 -param:HOJE = 18/12/2015 -param:SEMANAPASSADA = 11/12/2015
可能更接近你想要的东西。