Hello dipit,

Welcome to the Monastery. It is really difficult for us to replicate your problem without having input data (sample of table).

Having said that, I have found MySQL select statements in the past failing because of not using back ticks (``). So try something like this:

my $sql = "select distinct `FID_CUST` from `session` where `DAT_END` between `$key` and `$hash{$key}`";

Give it a try and let us know if it worked.

Update: I have found really useful the phpMyAdmin it helps me to check my requests before applying them.

Update2: In case the SELECT statement is correct run something like this as fellow monk talexb proposed:

eval { ### Catch _any_ kind of failures from the code within ### Enable auto-error checking on the database handle $dbh->{RaiseError} = 1; ### Prepare a SQL statement for execution my $sth = $dbh->prepare( "select distinct `FID_CUST` from `session +` where `DAT_END` between `$key` and `$hash{$key}`" ); while (1) { ### Execute the statement in the database $sth->execute(); ### Retrieve the returned rows of data while ( my @row = $sth->fetchrow_array() ) { print "Row: @row\n"; } } }; warn "Monitoring aborted by error: $@\n" if $@;

Looking forward to your update, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Code flow not going to while loop by thanos1983
in thread Code flow not going to while loop by dipit

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.