BillB has asked for the wisdom of the Perl Monks concerning the following question:
I am using the following match to search a sql script
if $ScanString =~ m/insert\s.+doc.+[\(|values|select|;]?/is;It is returning true on the following code fragment. What I want is that if the table name of DOC follows the INSERT, but if it gets to any of "(", SELECT or ";" it will return false. In other words if the DOC is not there before I hit "(", SELECT or ";" it will always return false. The perl match from above is returning a false positive because the string "DOC_NUM" is in the attached select. However the full script can have many inserts. If any of them match the pattern I want it to be true. If none of them match I want the test to be false. Any help would be appreciated. The script fragment follows
INSERT INTO gl_trn ( CO_CD, GL_ACCT_CD, JRNL_CD, EMP_CD_OP, POST_DT, DES, REF, DC_CD, AMT, TRN_DT, GL_TRN_ORIGIN_CD, FINAL_DT, CO_UNIT, TRN_TIME, CMNT, BNK_ACCT_CD, BNK_TRN_TP_CD, DOC_NUM, POST_ID_NUM, BNK_CO_CD) SELECT 'XXX', GL_ACCT_CD, NULL, EMP_CD_OP, to_date('&to_post_dt', 'MMD +DRR'), 'REVERSAL'||' '||substr(des, 1, 30), 'R'||substr(REF, 1, 18), decode(dc_cd, 'C', 'D', 'D', 'C'), amt, TRUNC(SYSDATE), gl_trn_origin_cd, NULL, co_unit, floor((sysdate-trunc(sysdate))*86400), 'Auto-generated by DEV using ACREV', BNK_ACCT_CD , BNK_TRN_TP_CD, DOC_NUM, POST_ID_NUM , BNK_CO_CD FROM gl_trn WHERE post_dt = to_date('&from_post_dt', 'MMDDRR') AND jrnl_cd = 'A' AND co_cd = 'RAY' AND NOT EXISTS (SELECT 'X' FROM gl_reversed g WHERE g.GL_TRN_SEQ_NUM = gl_trn.gl_trn_seq_num);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can I have a hard stop on a match
by haukex (Archbishop) on Nov 17, 2017 at 14:16 UTC | |
|
Re: Can I have a hard stop on a match
by Eily (Monsignor) on Nov 17, 2017 at 14:04 UTC | |
|
Re: Can I have a hard stop on a match
by roboticus (Chancellor) on Nov 17, 2017 at 14:01 UTC | |
|
Re: Can I have a hard stop on a match
by holli (Abbot) on Nov 17, 2017 at 14:04 UTC | |
by haukex (Archbishop) on Nov 17, 2017 at 14:26 UTC | |
|
Re: Can I have a hard stop on a match
by AnomalousMonk (Archbishop) on Nov 17, 2017 at 16:51 UTC | |
|
Re: Can I have a hard stop on a match
by 1nickt (Canon) on Nov 17, 2017 at 14:02 UTC |