Author |
Message
|
prasad.gh789 |
Posted: Wed Aug 06, 2014 4:36 am Post subject: File validation against File pattern |
|
|
Novice
Joined: 06 Aug 2014 Posts: 20
|
Hi all Please Help me
My input file is flat file name pattern is like this
Format of filename TSTxxxxxxyyyymmddss (19 characters)
xxxxxx = Identifier of the sender of the Toll Station Table file, originated by a TC (6 characters).
yyyy = Year (4 characters)
mm = Month (2 characters)
dd = Date (2 characters) ss = Sequence within the day (sequential number of 2 characters increased separately for each file per each sender/receiver combination per day beginning with 01)
we get this message from remote FTP and then by using FILTER node we need to validate the file by using file name format
please provide me the ESQL code for this requirement. i am fresher soo i need help. tomorrow is the delivery
thank you |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 06, 2014 4:41 am Post subject: Re: File validation against File pattern |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
prasad.gh789 wrote: |
please provide me the ESQL code for this requirement. |
Where do we send the invoice? Like you, we get paid to write ESQL.
prasad.gh789 wrote: |
i am fresher soo i need help. |
Yes you do. You should mention that to whoever gave you the requirement.
prasad.gh789 wrote: |
tomorrow is the delivery |
You should mention that to whoever gave you the requirement as well; something along the line of expecting a fresher with no help to deliver code in 1 business day is a bit optimistic on their part.
You should also mention that any code you do produce actually comes from a bunch of anonymous and unaccountable strangers on the Internet so in the event of problems (or future development) that's going to be problematic, and actually getting the fresher in question some locally based mentoring & realistic deadlines is the way to go. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 06, 2014 4:50 am Post subject: Re: File validation against File pattern |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
prasad.gh789 wrote: |
Format of filename TSTxxxxxxyyyymmddss (19 characters)
xxxxxx = Identifier of the sender of the Toll Station Table file, originated by a TC (6 characters).
yyyy = Year (4 characters)
mm = Month (2 characters)
dd = Date (2 characters) ss = Sequence within the day (sequential number of 2 characters increased separately for each file per each sender/receiver combination per day beginning with 01)
|
But because it's Wednesday:
Code: |
SET cIdentifier=SUBSTRING(InputLocalEnvironment.File.Name FROM 3 FOR 6);
SET dDate=CAST(SUBSTRING(InputLocalEnvironment.File.Name FROM 9 FOR 8) AS DATE FORMAT 'yymmdd');
SET iSequence=CAST(SUBSTRING(InputLocalEnvironment FROM 17 FOR 2) AS INTEGER);
IF iSequence +1 <> iWhateverTheLastSequenceNumberWas THEN
THROW USER EXCEPTION MESSAGE "We're all going to die";
END IF;
|
You can spend from now until delivery tomorrow finishing that, and fixing the bugs I've quite deliberately put into it which I'd be obliged if no-one else chips in on.
Teach a fresher to fish and all that.... _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Aug 06, 2014 4:56 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
In addition to my colleagues comments,
This bit
Quote: |
then by using FILTER node we need to validate the file by using file name format
|
Sounds like the 'designer' does not know the product very well.
Their thinking may well have been...
We need to filter out some files. :Lightbulb moment, I know, we can use a filter node
to prescribe to a novice the type of node to use for doing this validation is in my mind the sign of a badly formed requirement.
What happens if you can't meet the requirement using a 'filter node'? Can you switch to a more flexible compute node? Or do you fail?
If you have not received proper training in the product AND have experience in setting up File nodes for FTP then there is no way, 1 day is adequate for this task. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 06, 2014 5:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
smdavies99 wrote: |
Their thinking may well have been...
We need to filter out some files. :Lightbulb moment, I know, we can use a filter node |
Now what's wrong with "filtering" files out by throwing an exception if the name doesn't match? I mean, they go into the backout folder...
1 day for the whole task is optimistic even assuming the concept is sound (hah!) and the person charged with the task has a level of expereince. The OP has been thrown in the deep end after being given an anvil to hold, hence the example code from me of all people (!) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Aug 06, 2014 7:40 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Vitor wrote: |
smdavies99 wrote: |
Their thinking may well have been...
We need to filter out some files. :Lightbulb moment, I know, we can use a filter node |
Now what's wrong with "filtering" files out by throwing an exception if the name doesn't match? I mean, they go into the backout folder...
1 day for the whole task is optimistic even assuming the concept is sound (hah!) and the person charged with the task has a level of expereince. The OP has been thrown in the deep end after being given an anvil to hold, hence the example code from me of all people (!) |
nothing wrong with that but it sometimes takes a while to understand the subtle differences between the message tree used in a Filter Node and a Compute Node. I've not looked at your code in details so I don't want to say any more. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
McueMart |
Posted: Wed Aug 06, 2014 8:09 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Code: |
SET cIdentifier=SUBSTRING(InputLocalEnvironment.File.Name FROM 3 FOR 6);
SET dDate=CAST(SUBSTRING(InputLocalEnvironment.File.Name FROM 9 FOR 8) AS DATE FORMAT 'yymmdd'); -- 3 mistakes (that's just mean)
SET iSequence=CAST(SUBSTRING(InputLocalEnvironment FROM 17 FOR 2) AS INTEGER); -- 1 mistake
IF iSequence +1 <> iWhateverTheLastSequenceNumberWas THEN -- 1 mistake
THROW USER EXCEPTION MESSAGE "We're all going to die";
END IF; |
 |
|
Back to top |
|
 |
paustin_ours |
Posted: Wed Aug 06, 2014 9:15 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Quote: |
please provide me the ESQL code for this requirement. i am fresher soo i need help. tomorrow is the delivery
|
good example of modern day slavery. The so called IT outsourcing giants exploiting people. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 06, 2014 9:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
McueMart wrote: |
Code: |
SET cIdentifier=SUBSTRING(InputLocalEnvironment.File.Name FROM 3 FOR 6);
SET dDate=CAST(SUBSTRING(InputLocalEnvironment.File.Name FROM 9 FOR 8) AS DATE FORMAT 'yymmdd'); -- 3 mistakes (that's just mean)
SET iSequence=CAST(SUBSTRING(InputLocalEnvironment FROM 17 FOR 2) AS INTEGER); -- 1 mistake
IF iSequence +1 <> iWhateverTheLastSequenceNumberWas THEN -- 1 mistake
THROW USER EXCEPTION MESSAGE "We're all going to die";
END IF; |
|
I didn't have to offer any code, and under other circumstances I wouldn't.
And you missed a couple.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
prasad.gh789 |
Posted: Tue Aug 12, 2014 11:21 pm Post subject: |
|
|
Novice
Joined: 06 Aug 2014 Posts: 20
|
Thank you soooo much for all your support. |
|
Back to top |
|
 |
|