Hi All,
I have a specific requirement of adding a column conditionally to a target sequential file. I am looking for the best way of doing it.
To put it in detail, the source can have two columns Col1, Col2. Col1 always goes to target file (which is a sequential file) but Col2 should be added to target only if it satisfies a condition. Assuming that there is only one record in source, what will be the best way to achieve this?
I think we can't use RCP as it is blocked by the conditional addition of the column on contrary to unconditional addition.
I have a workaround using sequences but I am interested to see if there is any better way. Appreciate your interest in this.
Best way to add a column conditionally to a sequential file
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
For this to work you must set "First line is column headings" to False.
Always send one column. It may be derived as InLink.Col1 or it may be derived as InLink.Col1 : "," : InLink.Col2 in a Transformer stage.
Wrap these two possiblilties in an If..Then..Else construct to manage your condition, and amend the delimiter character appropriately.
Always send one column. It may be derived as InLink.Col1 or it may be derived as InLink.Col1 : "," : InLink.Col2 in a Transformer stage.
Wrap these two possiblilties in an If..Then..Else construct to manage your condition, and amend the delimiter character appropriately.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Thanks all for the replies. Sorry for late reply.
@Ray, It's a nice approach. I was also thinking of column export and import stages for similar approach. I was wondering, however, how can we generate record of column names in the latter case (while processing row#1). I guess for this we might need to use either a row generator stage or a funnel stage after transformer.
I hope you are suggesting to use a record delimiter for row#1 like below:
If Row#=1 Then <Col_Names> <Rec_Delim> <Col_Values>
@Ray, It's a nice approach. I was also thinking of column export and import stages for similar approach. I was wondering, however, how can we generate record of column names in the latter case (while processing row#1). I guess for this we might need to use either a row generator stage or a funnel stage after transformer.
I hope you are suggesting to use a record delimiter for row#1 like below:
If Row#=1 Then <Col_Names> <Rec_Delim> <Col_Values>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: