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' )^;

In reply to Re: query linking by monarch
in thread query linking by ritzi86

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.