Yeah. It looks like a typo.

Suspend this thread until I get a short program with no typos that
exhibits the incorrect behavior.


On 2/21/06, Terence J. Young, D.C. <[EMAIL PROTECTED]> wrote:
> Aren't you missing the..
>
> my $sql = $self->{load_statement};
>
> part in the main code??
>
> Matthew Persico wrote:
>
> >One of my programmers is reporting this. In my heart I believe its got
> >to be a stupid-perl-typo-that-we-don't-see, but since we both cannot
> >see it, I submit it to the community at large, with asbestos underwear
> >firmly in place.
> >
> >The gist of the problem is that we are connecting to an IQ database
> >and in one instance, the load database call indicates no errors but
> >does not work. In the other instance, it does work.
> >
> >Here's the code:
> >
> >1: This does not work with load table, althouth it does work with select and
> >insert statements. (i.e., the statement is executed on a de-referenced 
> >statement
> >handle).
> >
> >The 'main' code:
> >
> >      my ($self) = @_;
> >      my $sth = undef;
> >      my $ret = undef;
> >      my $dbh = $self->{dbh}; ## dbh previously succesfully opened
> >      print "Load Statement: \n $self->{load_statement} \n";
> >
> >      my $ret = _dbi_execute($dbh, \$sth, $sql); ## See def below
> >      if ($ret) {
> >            if ($self->{dbh}->commit()) {
> >                  print "IQ Commit $ret rows.";
> >                  return($ret);
> >            }
> >            else {
> >                 print "Error on IQ Commit";
> >                  return(undef);
> >            }
> >      }
> >
> >      # $ret comes back successful, but the load table does not really 
> > happen.
> >
> >#-------------------------------------------------------------------------------------------------
> >sub _dbi_execute {
> >      my ($dbh, $psth, $sql) = @_;
> >
> >      unless ($dbh) {
> >            print "Error: Database Handle is not defined.";
> >            return(undef);
> >      }
> >      my $ret = undef;
> >
> >      eval {
> >            $$psth = $dbh->prepare($sql);
> >      };
> >      if (($@) || (!$$psth)) {
> >            my $errstr = $dbh->errstr();
> >            print "DBI Prepare Error: $@ $errstr ";
> >            return(undef);
> >      }
> >
> >      eval {
> >            $ret = $$psth->execute();
> >      };
> >      if (($@) || (!$$psth)) {
> >            my $errstr = $$psth->errstr();
> >            print "DBI Execute Error: $@ $errstr ";
> >            return(undef);
> >      }
> >
> >      return($ret);
> >}
> >#-------------------------------------------------------------------------------------------------
> >
> >
> >
> >2:   This works (i.e., the statement handle is declared and used in the same
> >subroutine).
> >#-------------------------------------------------------------------------------------------------
> >sub load_iq {
> >      my ($self) = @_;
> >      my $sth = undef;
> >      my $ret = undef;
> >      my $dbh = $self->{dbh};
> >      LogEcho("Load Statement: \n $self->{load_statement} \n");
> >
> >      eval {
> >            $sth = $dbh->prepare($self->{load_statement});
> >      };
> >
> >      if (($@) || (!$sth)) {
> >            my $errstr = $dbh->errstr();
> >            print "DBI Prepare Error: $@ $errstr ";
> >            return(undef);
> >      }
> >
> >      eval {
> >            $ret = $sth->execute();
> >      };
> >      if (($@) || (!$ret)) {
> >            my $errstr = $sth->errstr();
> >            print "DBI Execute Error: $@ $errstr ";
> >            return(undef);
> >      }
> >
> >      if ($ret) {
> >            if ($self->{dbh}->commit()) {
> >                  print "IQ Commit $ret rows.";
> >                  return($ret);
> >            }
> >            else {
> >                 print "Error on IQ Commit";
> >                  return(undef);
> >            }
> >      }
> >}
> >
> >--
> >Matthew O. Persico
> >
> >
> >
>


--
Matthew O. Persico

Reply via email to