in reply to query linking
You had a preview button and you didn't use it.
This is my interpretation of your code, laid out in a more readable manner. Just out of curiosity, what company is this code coming from?
# Query the database for a list of accounts, # contracts and products that are of interest. # Where "of interest" is defined as may have # terminated a required product in the last # 2 months. my $sqlcmd=qq^ SELECT cmf.account_no, cc.contract_type, to_char(cc.start_dt,'mon dd YYYY HH:MM:ss') start_dt, ciem.external_id, emf_p.element_id, to_char(emf_p.product_inactive_dt, 'mon dd YYYY HH:MM:ss') product_inactive_dt FROM CMF cmf, CUSTOMER_CONTRACT cc, SERVICE emf, SERVICE emf_c, PRODUCT emf_p, CUSTOMER_ID_EQUIP_MAP ciem , product_charge_map pcm WHERE cmf.account_no = emf_c.parent_account_no AND ( (cmf.account_no = cc.parent_account_no AND cc.contract_level = 1 ) OR (emf_c.subscr_no = cc.parent_subscr_no AND emf_c.subscr_no_resets = cc.parent_subscr_no_resets AND cc.contract_level = 3 ) )^; # Add list of interesting contracts. $sqlcmd ="$sqlcmd AND ("; $i = 0; foreach $contract_key (sort(keys(%contracts))) { $sqlcmd="$sqlcmd cc.contract_type = $contract_key"; $i++; if ($i < $contract_count) { $sqlcmd=" $sqlcmd OR "; } } $sqlcmd="$sqlcmd )"; $sqlcmd =qq^ $sqlcmd AND (cc.end_dt is NULL OR cc.end_dt >= emf_p.product_inactive_dt) AND cmf.account_no = emf.parent_account_no AND emf.subscr_no = emf_c.subscr_no AND emf.subscr_no = ciem.subscr_no AND emf.subscr_no_resets = ciem.subscr_no_resets AND ciem.external_id_type = 1 AND emf.subscr_no = emf_p.parent_subscr_no AND emf.subscr_no_resets = emf_p.parent_subscr_no_resets AND emf_p.tracking_id =pcm.tracking_id AND emf_p.tracking_id_serv=pcm.tracking_id_serv AND emf_p.parent_account_no=pcm.parent_account_no AND PCM.inactive_dt is not NULL AND PCM.billed_thru_dt is not NULL AND emf_p.product_inactive_dt <= to_date('$now','mm/dd/yyyy') AND emf_p.product_inactive_dt > to_date('$one_month','mm/dd/yyyy' )^;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: query linking
by monarch (Priest) on Feb 11, 2009 at 03:51 UTC | |
by CountZero (Bishop) on Feb 11, 2009 at 07:00 UTC | |
|