The flow for a dbi query that returns data is:
1. Define statement
2. Prepare statement
3. Execute statement
4. Fetch results of statement

You're missing step 3. You're code should look like this:
sub _get_billing_plan_options { my $self = shift; my @billing_plan_options; my $sql = $self->{'cfg'}->param("sql.get_svc_plan_options"); $self->log('DEBUG','->_get_billing_plan_options() says our query is: + ' . $sql); my $sth = $self->{'dbh'}->prepare($sql); $self->log('DEBUG','Our $sth is: ',$sth); #you have to execute the prepared query! $sth->execute(); while (my $options = $sth->fetchrow_hashref()){ $options->{'plan_type'} =~ s/_/ /; push @billing_plan_options, [ 'service_plan_' . $options->{'svc_pl +an_id'}, $options->{'plan_name'}, $options->{'plan_type'} ]; push @billing_plan_options, [ 'service_plan_prepay_' . $options->{ +'svc_plan_id'}, $options->{'plan_name'}, $options->{'plan_type'} ]; } #Don't forget to finish the statement handle $sth->finish; return \@billing_plan_options; }

In reply to Re: Baffled by "fetchrow_hashref failed: no statement executing" by jrsimmon
in thread Baffled by "fetchrow_hashref failed: no statement executing" by hesco

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.