Couple of quick comments.

As already mentioned, "=" will almost always evaluate as true (however, if $Data{"CustomerNumber"} evaluates as false, then the entire statement will be false).

First, print out the SQL.

my $sql = "SELECT * FROM Cust_act_da WHERE CustomerNumber = $CustomerN +umber AND #TransType = P"; print $sql; $db->SQL( $sql );
Once you see the SQL, the error may be obvious. If not, try running the SQL manually and see what the results are.

Also, as a general rule, "select *" is generally not a good way to execute an SQL query (IMHO). It's not as efficient as selecting specifically what you want. Further, if the field names have been changed, this may obscure where your error is coming from.

Another thing that concerns me is that I see you are printing  . This suggests that this information is being printed to a Web page. What is the original source of the data? Blindly printing data to a Web page doesn't usually cause problems (though someone could insert a meta refresh tag that redirects your page), but since you don't untaint this data, I am concerned about what else you may be doing with this data that may be dangerous.

Of course, that last comment is totally unrelated to your question, but I always harp about anything that suggests to me that a poor security model is being used. No offense. See perlsec for more information.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: Loop Question by Ovid
in thread Loop Question by Anonymous Monk

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.