Basically it should identify what ever is in between /< >/ (tags) and replace dbname ending with (.) with the words in between the tags
i.e.
DELETE FROM /*<workDB>*/epd_test./*<multi>*//*<version>*/epd_tbl1 ALL; into
DELETE FROM /*<workDB>*/${workDB}./*<multi>*//*<version>*/${multi}${version}_epd_tbl1 ALL;
one more example
DELETE FROM /*<abcDB>*/epd_test./*<multi>*//*<version>*/epd_tbl1 ALL; into
DELETE FROM /*<abcDB>*/${abcDB}./*<multi>*//*<version>*/${multi}${version}_epd_tbl1 ALL;
what I was thinking was to remember /< as pattern 1 i.e \(\/\<\) and workDB as one more pattern >*/ as one more pattern and identify until the
period and replace as above? Is this doable
and similarly for dates it replace with in the single quotes with out using from_dt
sample.sql contains:
DELETE FROM /*<workDB>*/epd_test./*<multi>*//*<version>*/epd_tbl1 ALL;
INSERT INTO /*<workDB>*/epd_test./*<multi>*//*<version>*/epd_tbl1
SELECT
*
FROM
/*<finDB>*/epd_fin.pr_tbl
WHERE
( epd_dt >= cast(/*<from_date>*/'2007-01-01' as date)
AND epd_dt < cast(/*<to_date>*/'2009-09-14' as date)
)
OR ( epd_cre_dt >= cast(/*<from_date>*/'2007-01-01' as date)
AND epd_cre_dt < cast(/*<to_date>*/'2009-09-14' as date)
)
;
output should be:
DELETE FROM /*<workDB>*/${workDB}./*<multi>*//*<version>*/${multi}${version}_epd_tbl1 ALL;
INSERT INTO /*<workDB>*/${workDB}./*<multi>*//*<version>*/${multi}${version}_epd_tbl1
SELECT
*
FROM
/*<finDB>*/${finDB}.pr_tbl
WHERE
( epd_dt >= cast(/*<from_dt>*/'${from_dt}' as date)
AND epd_dt < cast(/*<to_dt>*/'${to_dt}' as date)
)
OR ( epd_cre_dt >= cast(/*<from_dt>*/'${from_dt}' as date)
AND epd_cre_dt < cast(/*<to_dt>*/'${to_dt}' as date)
)
;
Thanks in advance