How to split into n number of records from one record

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

Post Reply
deva
Participant
Posts: 104
Joined: Fri Dec 29, 2006 1:54 pm

How to split into n number of records from one record

Post by deva »

Hi,

I have one table the formate is

idno, amount, begin_dt, end_dt, no.Premiums

1 4000 01-06-2005 31-06-2005 4

if i have no.Premiums are 4 I need o/p with 4 records

from the above record , into target I have get 4 records based on the no of Premiums.

required o/p is
idno,instal_amt,due_date

1 1000 03-06-2005
1 1000 06-06-2005
1 1000 09-06-2005
1 1000 12-06-2005

Thanks in advance
DeepakCorning
Premium Member
Premium Member
Posts: 503
Joined: Wed Jun 29, 2005 8:14 am

Re: How to split into n number of records from one record

Post by DeepakCorning »

The only thing that I can think of is to create a base job , and put it in a loop for the number Premium. Everytime when its called do a select like

Select idno, amount / noPremiumns, begin_dt + ___ from table.

this may not be an ideal solution as it will be a heck of performance hogger. But it will do wht u want to do. I will try to come up with something more effective.
Thanks
Deepak Patil

Convince Them Confuse Them .. What's the difference?
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: How to split into n number of records from one record

Post by gateleys »

I would NOT run the job in a loop. Rather, run the job only once, however, with a call to a routine that writes as many rows as there are Premiums.
gateleys
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Definitely a routine. What are the rules for establishing the dates and premium amount in the individual output records? It would be a Very Good Idea to document these business rules before designing anything, and getting agreement (sign off) that the specification is correct.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
deva
Participant
Posts: 104
Joined: Fri Dec 29, 2006 1:54 pm

Post by deva »

ray.wurlod wrote:Definitely a routine. What are the rules for establishing the dates and premium amount in the individual output records? It would be a Very Good Idea to document these business rules before designin ...
we have to split the dates and premium amount based on the no of premiums.

Can any one please provide the routine for this.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

deva wrote:Can any one please provide the routine for this.
That's the kind of thing consultants charge money to do.

I still don't believe that "we have to split the dates and premium amount based on the no of premiums" is a sufficient specification. If you had the adverb "equally" in there somewhere it would help (if true). But are there extra rules, like every date has to be a Friday, that you have not revealed?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
SHARAD123
Premium Member
Premium Member
Posts: 54
Joined: Wed Jan 09, 2008 12:05 am

Post by SHARAD123 »

Hi,
I suggest u to pass the premium as a parameter to a stored proc through OCI stage. Then write your business logic based on the parameter number. i hope this meets the requirement
222102
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Post by sachin1 »

i agree with gateleys, you need to create a routine which will take necessary input parameter and file name, file needs to be in append mode(opened and closed for each record processing).

Using stage variable you create a long string with a new line character as separator for each record, then try to write this long string with transformation routine.
Post Reply