Execute Command Stage in Sequencer Job

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

jpnrd
Participant
Posts: 19
Joined: Wed May 05, 2010 3:35 pm

Post by jpnrd »

The Director log result for Execute Command is


SequencerTest1..JobControl (@Execute_Command_12): Executed: printf $(<D:\DataFiles\ETL_DEV_Seq_Files\Policy_MaxModelDate.txt>)
Reply=0
Output from command ====>

SequencerTest1..JobControl (@Execute_Command_12): Checkpointed execution of command 'printf $(<D:\DataFiles\ETL_DEV_Seq_Files\Policy_MaxModelDate.txt>)'


and Job parameter Data Type in Px_Etl_Unld_Pc_PolicyPeriod_TodaysDate1 is String....
Thanx
Jaya
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Do not use closing angle bracket in printf. Try printf or cat command with tr.

Code: Select all

printf "$(<D:\DataFiles\ETL_DEV_Seq_Files\Policy_MaxModelDate.txt)"
Or

Code: Select all

cat D:\DataFiles\ETL_DEV_Seq_Files\Policy_MaxModelDate.txt | tr -d '\n'
You are the creator of your destiny - Swami Vivekananda
jpnrd
Participant
Posts: 19
Joined: Wed May 05, 2010 3:35 pm

Post by jpnrd »

Hey Anbu,

Now I am getting

SequencerTest1..JobControl (@Execute_Command_12): Executed: cat D:\DataFiles\ETL_DEV_Seq_Files\Policy_MaxModelDate.txt | tr -d '\n'
Reply=0
Output from command ====>
ModelDateMax
2010-05-26 03:34:44
Thanx
Jaya
jpnrd
Participant
Posts: 19
Joined: Wed May 05, 2010 3:35 pm

Post by jpnrd »

I think I need to eliminate that ModelDateMax now which is the column name
Thanx
Jaya
jpnrd
Participant
Posts: 19
Joined: Wed May 05, 2010 3:35 pm

Post by jpnrd »

Anbu,

I modified the sequential file settings so that I am getting

SequencerTest1..JobControl (@Execute_Command_12): Executed: cat D:\DataFiles\ETL_DEV_Seq_Files\Policy_MaxModelDate.txt | tr -d '\n'
Reply=0
Output from command ====>
2010-05-26 03:34:44



now I got this in sequence job. But still same in error is coming from the
job Px_Etl_Unld_Pc_PolicyPeriod_TodaysDate1

SQLServer_Enterprise_0,0: [IBM (DataDirect OEM)][ODBC SQL Server Driver][SQL Server]Conversion failed when converting datetime from character string.
Thanx
Jaya
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

I am not sure whether tr command removes newline character.

Just pass first 19 chars to your job Px_Etl_Unld_Pc_PolicyPeriod_TodaysDate1 from sequence job

Code: Select all

ExecuteCmd.$CommandOutput[1,19]
You are the creator of your destiny - Swami Vivekananda
jpnrd
Participant
Posts: 19
Joined: Wed May 05, 2010 3:35 pm

Post by jpnrd »

Hey Anbu,

I ran Successfully. You are really a Great HELP!!!! Thank You For all Your Support....
Thanx
Jaya
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The return value is actually a dynamic array, so one other solution would be to take just the first element from it:

Code: Select all

ExecuteCmd.$CommandOutput<1>
Another would be to strip the Field Mark that is added to the return value:

Code: Select all

Convert(@FM,"",ExecuteCmd.$CommandOutput)
Both of those solutions would be size / datatype 'agnostic'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kfb_developer
Premium Member
Premium Member
Posts: 13
Joined: Wed Feb 24, 2010 9:41 am

Execute Command

Post by kfb_developer »

chulett wrote:The return value is actually a dynamic array, so one other solution would be to take just the first element from it:

Code: Select all

ExecuteCmd.$CommandOutput<1>
Another would be to strip the Field Mark that is added to the return value:

Code: Select all

Convert(@FM,"",ExecuteCmd.$CommandOutput)
Both of those solutions would be size / datatype 'agnostic'.

What if we want to output a integer value using Execute Command... Do we need to use ExecuteCmd.$CommandOutput or ExecuteCmd.$ReturnValue.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

ExecuteCmd.$CommandOutput or ExecuteCmd.$ReturnValue depends upon how you return 2 from your script.

If your script returns value using any command like echo or printf then use ExecuteCmd.$CommandOutput else if you return value using return then use ExecuteCmd.$ReturnValue.

If you are using command output, then make sure you delete newline char at the end of your output or use printf command.
You are the creator of your destiny - Swami Vivekananda
kfb_developer
Premium Member
Premium Member
Posts: 13
Joined: Wed Feb 24, 2010 9:41 am

Post by kfb_developer »

Thanks for your reply anbu

I am using Cat filename.txt to read a integer value in text file into a job parameter for the next job activity stage. For date datatype the solution you told above is working fine. For integer how to delete that new line char? Do we need to use anything other that Cat for integer datatype like Printf or echo?
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Read the file using printf command

Code: Select all

printf $(< filename)
Or

You can run the script which has

Code: Select all

printf 2
You are the creator of your destiny - Swami Vivekananda
kfb_developer
Premium Member
Premium Member
Posts: 13
Joined: Wed Feb 24, 2010 9:41 am

Post by kfb_developer »

The job is getting failed throwing me these errors

Seq_Load_TQC05_POLICY..JobControl (@Execute_Command_43): Executed: printf $(<D:\DataFiles\ETL_DEV_MaxSurrKeyFiles\TQC05_POLICY_Max_SRC_SYS_ID.txt)
Reply=1
Output from command ====>
The system cannot find the file specified.



Seq_Load_TQC05_POLICY..JobControl (@Job_Activity_46): Controller problem: Error calling DSSetParam(Jp_MaxSrcSysID), code=-4
[ParamValue/Limitvalue is not appropriate]
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

$(< file) might not work in windows.

Then use cat and strip newline character as mentioned by Chulett
You are the creator of your destiny - Swami Vivekananda
kfb_developer
Premium Member
Premium Member
Posts: 13
Joined: Wed Feb 24, 2010 9:41 am

Post by kfb_developer »

It worked Thanks Chulet and Anbu.... :D :D
Post Reply