I have to do some changes in a xml. I have to add column-referneces to certain tables with column-refernces ending with _SK.
The file looks like this (i have marked the columns in bold):
<table name="RA_F_B2_XV" skip-update="false">
<column-ref name="B2_SK"/>
<column-ref name="QRRFLG"/>
<column-ref name="RWBAAS"/>
<column-ref name="RWBFAS"/>
<column-ref name="INST_ID"/>
<column-ref name="UNDISCD"/>
<column-ref name="ORGNOTAMT"/>
<column-ref name="QRRLIMCPY"/>
<column-ref name="RWABAAGRS"/>
<column-ref name="RWABFAGRS"/>
<column-ref name="RWBAAEPES"/>
<column-ref name="SEVAVGTRN"/>
<column-ref name="RATSCEUSED"/>
<column-ref name="OVDUEDYSASV"/>
<column-ref name="PRDCPYWGTP1"/>
<column-ref name="PAY_CTRCTAMT"/>
<column-ref name="RCVYAMTPLYTD"/>
<column-ref name="RCV_CTRCTAMT"/>
<column-ref name="RWABAAGREPES"/>
<column-ref name="DBETY_LEID_SK"/>
<column-ref name="ORGNOTAMT_FLG"/>
<column-ref name="REMLIFETIMEB2_GK_SK"/>
</table>
<table name="RA_D_DBETY_LEID_IS_V" skip-update="false">
<column-ref name="DBETY_LEID_SK"/>
<column-ref name="DBETY_LEID_L1_BK"/>
<column-ref name="DBETY_LEID_L1_SK"/>
<column-ref name="DBETY_LEID_L2_BK"/>
<column-ref name="DBETY_LEID_L2_SK"/>
<column-ref name="DBETY_LEID_L3_BK"/>
<column-ref name="DBETY_LEID_L3_SK"/>
<column-ref name="DBETY_LEID_BK"/>
<column-ref name="DBETY_LEID_L1_DESC"/>
<column-ref name="DBETY_LEID_L2_DESC"/>
<column-ref name="DBETY_LEID_L3_DESC"/>
<column-ref name="DBETY_LEID_DESC"/>
</table>
<table name="RA_D_DBETY_LEID" skip-update="false">
<column-ref name="DBETY_LEID_SK"/>
<column-ref name="DBETY_LEID_L1_BK"/>
<column-ref name="DBETY_LEID_L1_SK"/>
<column-ref name="DBETY_LEID_L2_BK"/>
<column-ref name="DBETY_LEID_L2_SK"/>
<column-ref name="DBETY_LEID_L3_BK"/>
<column-ref name="DBETY_LEID_L3_SK"/>
<column-ref name="DBETY_LEID_BK"/>
<column-ref name="DBETY_LEID_L1_DESC"/>
<column-ref name="DBETY_LEID_L2_DESC"/>
<column-ref name="DBETY_LEID_L3_DESC"/>
<column-ref name="DBETY_LEID_DESC"/>
<column-ref name="X_PKEY"/>
</table>
The result should look like this:
<table name="RA_F_B2_XV" skip-update="false">
<column-ref name="B2_SK"/>
...
<column-ref name="DBETY_LEID_SK"/>
<column-ref name="DBETY_LEID_HSK"/>
...
</table>
...
<table name="RA_D_DBETY_LEID" skip-update="false">
<column-ref name="DBETY_LEID_SK"/>
<column-ref name="DBETY_LEID_HSK"/>
...
<column-ref name="DBETY_LEID_L1_SK"/>
<column-ref name="DBETY_LEID_L1_HSK"/>
...
<column-ref name="DBETY_LEID_L2_SK"/>
<column-ref name="DBETY_LEID_L2_HSK"/>
...
<column-ref name="DBETY_LEID_L3_SK"/>
<column-ref name="DBETY_LEID_L3_HSK"/>
...
</table>
To add these columns I had used WildEdit with the following:
Search for:
(?!<column-ref name="(B2|LCX|COLL|CTRY|DERIV|DISCL|DISCLDM|DLV_SK|RET|DMCTRY|DMLCG|DMP1|DMP1DRILL|ELEC|ELECDM|KWG13|SEC|P1|PRLGVA)_SK"/>)(<column-ref name="[^"]*)_SK"/>
Replace with:
$0
$2_HSK"/>
The alternative is used to prevent updating the table key columns (I had to do this for more files)
This works fine by the way. My problem is, that the tables are heterogenous and that the 2nd table (ending with 'IS_V') must not get these HSK-columns. I have tried to work this out by extending the lookahead expression but it doesn't work as expected. If I'm trying this:
(?!<table name="[^"]*IS_V".*?<column-ref name="(B2|LCX|COLL|CTRY|DERIV|DISCL|DISCLDM|DLV_SK|RET|DMCTRY|DMLCG|DMP1|DMP1DRILL|ELEC|ELECDM|KWG13|SEC|P1|PRLGVA)_SK"/>)(<column-ref name="[^"]*)_SK"/>
and using the same replacement expression it will update both the table key column and the columns of the IS_V-tables.
Did anyone have a solution that works? The alternative is to delete the redundant references maually from the tabledefinitions.
Regards,
Meisn
P.S.: Sorry for so much textinput but I thought this would help to understand this better.