How to clean up a file through server routine?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

How to clean up a file through server routine?

Post by Nripendra Chand »

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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

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?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

Post by Nripendra Chand »

Clean up means I want to delete all the existing data in the existing file and load it with new data through server routine.

Regards,
Nripendra Chand
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

Post by Nripendra Chand »

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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

Post by Nripendra Chand »

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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

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"
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

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
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post by talk2shaanc »

Alternate way, using @INROWNUM

Code: Select all

IF @INROWNUM = 1 THEN In.Line :CHAR(13):'New String' ELSE In.Line
instead of 1 or any other line number, you can use a job parameter. It would give you more flexibility
Shantanu Choudhary
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

Post by Nripendra Chand »

thanks for the valuable suggestions. now i can do the it without the routine code.

Regards,
Nripendra Chand
Pavan_Yelugula
Premium Member
Premium Member
Posts: 133
Joined: Tue Nov 23, 2004 11:24 pm
Location: India

Post by Pavan_Yelugula »

hi
Can you please give me some info about (In. Line) in the above posts. Is it a built in function. i am using 7.0.1 and i was not able to find it in any of the transformer sub divisions

Any inputs will be really helpful

Thanks and Regards
Pavan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

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.
Post Reply