Page 1 of 2

How to Capture File Name from Sequential File Stage

Posted: Mon Nov 21, 2005 2:13 pm
by dilsere2
Hi Guys,

I need to capture File Name from Sequential File stage by any means. Its little tough because I am not passing the file name as parameter it's hard-coded along with path. Any info will be appericated.

thanks,

Posted: Mon Nov 21, 2005 2:32 pm
by I_Server_Whale
Hi,

Are you saying that you have to capture the filename from the path name?

For ex:

Code: Select all


Path= c:\xyz\abc\pqr\filename.ext

If thats the case, then you use the DCOUNT function to count the delimiter "\" and then use the FIELD function to extract the last field which is nothing but the filename .

Let me know how it went.

Thanks!
Naveen.

Posted: Mon Nov 21, 2005 2:34 pm
by kcbland
There is no API for requesting such information. The only thing you can do is trick the job into telling you this information thru the job log, which you can then query using the API DSGetLogSummary. Unfortunately, most of those messages tend to be fatal.

I think you need to revisit why the file name is not parameterized and shared with other processes. Your task is most difficult.

How to Capture File Name from Sequential File Stage

Posted: Mon Nov 21, 2005 2:53 pm
by dilsere2
kcbland wrote:There is no API for requesting such information. The only thing you can do is trick the job into telling you this information thru the job log, which you can then query using the API DSGetLogSummary. Unfortunately, most of those messages tend to be fatal.

I think you need to revisit why the file name is not parameterized and shared with other processes. Your task is most difficult.
The job log doesn't tell what is the output file name that you have defined inside the stage....

Posted: Mon Nov 21, 2005 3:07 pm
by manteena
Hardcode the filename as the stage name, then get the stage name with DSGetStageInfo....... :lol:

Posted: Mon Nov 21, 2005 3:44 pm
by kcbland
manteena wrote:Hardcode the filename as the stage name, then get the stage name with DSGetStageInfo....... :lol:
Cheater, I assumed the file is fully qualified and stage/link names can't have slashes, dashes, dots, just underscores.

Re: How to Capture File Name from Sequential File Stage

Posted: Mon Nov 21, 2005 3:45 pm
by kcbland
dilsere2 wrote: The job log doesn't tell what is the output file name that you have defined inside the stage....
It does if the file to be opened can't be opened, or there's some other catastrophic issue, hence my reply that the file name only shows up under tragic circumstances.

Re: How to Capture File Name from Sequential File Stage

Posted: Mon Nov 21, 2005 3:49 pm
by dilsere2
kcbland wrote:
dilsere2 wrote: The job log doesn't tell what is the output file name that you have defined inside the stage....
It does if the file to be opened can't be opened, or there's some other catastrophic issue, hence my reply that the file name only shows up under tragic circumstances.
Tell what you think of this? After job is sucessfully completed i will write a BASIC codoe to export the file to get dsx file name then write script to pharse out the FileName...You guys have any other ideas...

Posted: Mon Nov 21, 2005 3:57 pm
by kcbland
Why does this sound like a variable value everytime the job runs, but is hardcoded? This makes no sense. Is someone changing this filename, compiling it, and running it? Can you at least get them to write it to an empty directory and then assume anything in that directory is the file you want?

Posted: Mon Nov 21, 2005 5:21 pm
by manteena
An XML job report will give you the file name with Directory name of the source or target file stages....try to read this report for filename...

NO CHEATING :wink:

Posted: Mon Nov 21, 2005 5:48 pm
by kcbland
manteena wrote:An XML job report will give you the file name with Directory name of the source or target file stages....try to read this report for filename...

NO CHEATING :wink:
You might just have the winning suggestion! :D

Posted: Mon Nov 21, 2005 7:03 pm
by kduke

Code: Select all

select 
   EVAL DS_JOBOBJECTS."@RECORD<6>" AS FILE_NAME FMT '45L',
   DS_JOBS.NAME AS JOB_NAME FMT '35L', 
   DS_JOBOBJECTS.NAME AS LINK_NAME FMT '35L'
from 
   DS_JOBOBJECTS, 
   DS_JOBS
where 
   DS_JOBOBJECTS.OLETYPE in ('CSeqOutput','CSeqInput') 
   and DS_JOBOBJECTS.OBJIDNO = DS_JOBS.JOBNO 
group by 
   FILE_NAME, 
   JOB_NAME,
   LINK_NAME
;

Posted: Mon Nov 21, 2005 10:18 pm
by elavenil
In addition to Kim Duke's SQL statement, add jobno filter in the WHERE clause to give you the file name for that job, which you are looking for.

HTWH.

Regards
Saravanan

Posted: Tue Nov 22, 2005 9:31 am
by dilsere2
elavenil wrote:In addition to Kim Duke's SQL statement, add jobno filter in the WHERE clause to give you the file name for that job, which you are looking for.

HTWH.

Regards
Saravanan
This is an SQL statement..how do i do this in Datastage?

Posted: Tue Nov 22, 2005 11:25 am
by kduke
Do a search on TCL commands and telnet.