1. //Run SQL1 to check if there is amortization
SQL1 =
SELECT distinct notnl from profile
WHERE ins_num = ins_num
AND param_seq_num= leg_num
IF SQL1 RETURNS ONE ROW THEN //there is no amortization in this leg
DO NOT GENERATE notionalStepSchedule/step
ELSE IF SQL1 RETURNS MORE THAN 1 ROW THEN
SQL2 =
SELECT START_DATE, NOTNL from profile
WHERE ins_num = ins_num
AND param_seq_num= leg_num
ORDER BY profile_seq_num
Run SQL2
FOR EACH ROW RETURNED BY SQL2 generate one step tag
<step>
<stepDate> START_DATE </stepDate> //FORMAT YYYY-MM-DD
<stepValue> NOTNL </stepValue>//FORMAT IT TO HAVE 6 DECIMALS.
</step>
Example:
Leg 1
Results of SQL1
2. The step tag must be generated, because number of rows returned is > 1
Results of SQL2
3. The xml generated will be like this
<notionalSchedule>
<notionalStepSchedule>
<initialValue>100000000</initialValue>
<step>
<stepDate>2013-01-15</stepDate>
<stepValue>100000000</stepValue>
</step>
<step>
<stepDate>2013-04-15</stepDate>
<stepValue> 88047213.615783 </stepValue>
</step>
<step>
<stepDate> 2013-07-15 </stepDate>
<stepValue> 75942029.205168 </stepValue>
</step>
<step>
<stepDate>2013-10-15</stepDate>
<stepValue> 63682503.693317 </stepValue>
</step>
<step>
<stepDate>2014-01-15</stepDate>
<stepValue> 51266669.231190 </stepValue>
</step>
<step>
<stepDate>2014-04-15</stepDate>
<stepValue> 38692532.879671</stepValue>
</step>
<step>
<stepDate>2014-07-15</stepDate>
<stepValue> 25958076.289669</stepValue>
</step>
<step>
<stepDate>2014-10-15</stepDate>
<stepValue> 13061255.378146</stepValue>
</step>
<notionalSchedule>
FOR LEG 2
4. SQL1 returned only 1 row
Then the step tag will not be generated.
<notionalSchedule>
<initialValue>100000000</initialValue>
</notionalSchedule>