How to clean up a file through server routine?
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 196
- Joined: Tue Nov 23, 2004 11:50 pm
- Location: Sydney (Australia)
How to clean up a file through server routine?
Hi,
i want to clean up the existing file through server routine and write the fresh data on it. please tell me which command i should use for this requirement.
Regards,
Nripendra
i want to clean up the existing file through server routine and write the fresh data on it. please tell me which command i should use for this requirement.
Regards,
Nripendra
Nripendra,
you will need to narrow down your question quite a bit. What do you mean by "clean"? What kind of file, what kind of additional data?
you will need to narrow down your question quite a bit. What do you mean by "clean"? What kind of file, what kind of additional data?
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The functionality you require is available as the "overwrite existing file" property of an input link to a Sequential File stage.
Don't use a routine. You're only reinventing the wheel and making your DataStage application more difficult for others to maintain.
Don't use a routine. You're only reinventing the wheel and making your DataStage application more difficult for others to maintain.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 196
- Joined: Tue Nov 23, 2004 11:50 pm
- Location: Sydney (Australia)
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Why did you purchase DataStage?
DataStage can do all that (see my earlier post). If you want to write your own routines, you've wasted a lot of money on DataStage.
To reiterate: use a server job, not a server routine.
DataStage can do all that (see my earlier post). If you want to write your own routines, you've wasted a lot of money on DataStage.
To reiterate: use a server job, not a server routine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 196
- Joined: Tue Nov 23, 2004 11:50 pm
- Location: Sydney (Australia)
the functionality is not just to overwrite the existing file. I have some data already in the file and i have to insert the new records in the appropriate locations in the existing file. Suppose I have ten lines in the existing file, my requirement is to delete 6th and 7th lines and insert two new lines instead of these two.
Regards,
Nripendra
Regards,
Nripendra
In order to replace lines in a sequential file you will need to use a temporary interim file, you cannot easily do this type of selective overwriting in a sequential file - in fact the only way to do this would be if the records are all of identical length.
Write a job that does a Sequential -> Transform -> Sequential type of work. Read your source in DS and write it to the temporary file without modification for most rows, use the condition in the Transform change to modify that data (i.e. your rows 6 & 7) and then pass that to your output.
No need for a programmed routine.
Write a job that does a Sequential -> Transform -> Sequential type of work. Read your source in DS and write it to the temporary file without modification for most rows, use the condition in the Transform change to modify that data (i.e. your rows 6 & 7) and then pass that to your output.
No need for a programmed routine.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That's not the same as your response of "delete all the existing data in the existing file" to which I responded.
I agree with Arnd on method for your newly-stated requirement. You will need an intermediate file - perhaps rename the source file before proceeding.
I agree with Arnd on method for your newly-stated requirement. You will need an intermediate file - perhaps rename the source file before proceeding.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 196
- Joined: Tue Nov 23, 2004 11:50 pm
- Location: Sydney (Australia)
the files looks like the following. i'm pasting just few sample lines:
<Development>
Migration Type : ONGOING
Warning Email Alert Required : No
Application Name :
Application Version :
<Testing>
Migration Type : ONGOING
Warning Email Alert Required : No
Application Name :
Application Version :
Now if I want to insert new line after Migration Type at both the places. then i think i have to use the routine because file delimiter is not same at all places.
Need your suggestions.
Regards,
Nripendra
<Development>
Migration Type : ONGOING
Warning Email Alert Required : No
Application Name :
Application Version :
<Testing>
Migration Type : ONGOING
Warning Email Alert Required : No
Application Name :
Application Version :
Now if I want to insert new line after Migration Type at both the places. then i think i have to use the routine because file delimiter is not same at all places.
Need your suggestions.
Regards,
Nripendra
Nripendra,
I'm not going to supply you with your code or solution; but why can you not use a derivation in your transform somewhat like "IF In.Line[1,9]='Migration' THEN 'NewL1':CHAR(13):'NewL2' ELSE In.Line"
I'm not going to supply you with your code or solution; but why can you not use a derivation in your transform somewhat like "IF In.Line[1,9]='Migration' THEN 'NewL1':CHAR(13):'NewL2' ELSE In.Line"
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
As you want to add 1 line , you can rewrite the transform code as
Code: Select all
IF In.Line[1,9]='Migration' THEN In.Line :CHAR(13):'NewL2' ELSE In.Line
-
- Charter Member
- Posts: 199
- Joined: Tue Jan 18, 2005 2:50 am
- Location: India
Alternate way, using @INROWNUM
instead of 1 or any other line number, you can use a job parameter. It would give you more flexibility
Code: Select all
IF @INROWNUM = 1 THEN In.Line :CHAR(13):'New String' ELSE In.Line
Shantanu Choudhary
-
- Premium Member
- Posts: 196
- Joined: Tue Nov 23, 2004 11:50 pm
- Location: Sydney (Australia)
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
Pavan,
columns in your stages have the naming convention <stagename>.[/b]<columnname>. Since we know neither your stage name nor your column name people will most often use examples like Link.Column or, in my case, In.Line or In.Column. All we are referring to here is the name of the column that you need to do the processing on.
columns in your stages have the naming convention <stagename>.[/b]<columnname>. Since we know neither your stage name nor your column name people will most often use examples like Link.Column or, in my case, In.Line or In.Column. All we are referring to here is the name of the column that you need to do the processing on.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>