RafaelCampos
RafaelCampos

Reputation: 109

Table Input Step Does not replace variables

I'm running the following code in the Input Step of Pentaho Kettle:

SELECT * FROM ${TABELA} WHERE TS_SAMPLETM BETWEEN TO_DATE('${HOJE}', 'DD/MM/YYYY') AND TO_DATE('${SEMANAPASSADA}','DD/MM/YYYY')

However, when I run the Job via this shell script:

#!/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

The Table Input step does not replace the variables.

Upvotes: 0

Views: 1815

Answers (1)

bolav
bolav

Reputation: 6998

Your problem is errors in your shell script, and not errors with Pentaho, or Table Input Step. If you try to insert echo before the sh on the last line you can see the command that is run:

echo sh kitchen.sh -file=/home/rafael/data-integration/Job_Oracle_MySql.kjb -param:TABELA=$TABELA -param:HOJE=$HOJE -param:SEMANAPASSADA=$SEMANAPASSADA

For me this outputs:

sh kitchen.sh -file=/home/rafael/data-integration/Job_Oracle_MySql.kjb -param:TABELA= -param:HOJE=18/12/2015 -param:SEMANAPASSADA=

The problems in your shellscript is

  1. case sensitive. Replace $TABELA with $tablea
  2. for me the way of calling date is wrong, but this depends on your OS, which you have not supplied. I need to write export SEMANAPASSADA=$(date -v -7d +"%d/%m/%Y")

After these changes when I run the script it outputs:

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

which probably is closer to what you want.

Upvotes: 1

Related Questions