I am having a problem now where the @rows eq "0" dows not appear to be working. @rows has a value and I have confirmed that it is correct. But the statement to see if the value is eq to 0 seems to be bypassed.
Here is the code :-
my $cth = $dbh->prepare('SELECT COUNT(*) FROM SuppressList WHERE A +ctive = ? AND ServerName = ? AND Application = ? and Instance = ?') o +r die "Couldn't Prepare statement: " . $dbh->errstr; $cth->execute($Active,$Server_Name,$App,$Inst); @rows = $cth->fetchrow_array(); cawto "Rows: @rows"; my ($sql, @placeholders); if (@rows ge "1") { $sql = qq{SELECT * FROM SuppressList WHERE Active = ? AND Serv +erName = ? AND Application = ? AND Instance = ?}; @placeholders = ($Active,$Server_Name,$App,$Inst); cawto "ServerName/App/Inst Execute Complete"; } else { $sql = qq{SELECT * FROM SuppressList WHERE Active = ? AND Serv +erName = ? AND Application = ?}; @placeholders = ($Active,$Server_Name,$App); cawto "ServerName/App Execute Complete"; } my $sth = $dbh->prepare($sql); $sth->execute(@placeholders);

I am lost... it appears to work then it actually doesn't. Any tips ?
Cheers
Danny

Update: Sorry forgot to add that I changed to ge from eq to see if that worked.. It doesn't. Also running this on Win32 platform.


In reply to Re^2: Using If statement to set DBI prepare by dtharby
in thread Using If statement to set DBI prepare by dtharby

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.