in reply to Re: Query works in sqlplus but not DBI
in thread Query works in sqlplus but not DBI - Solved

Thanks for the responses! Note in the code that I print out the entire query before it gets passed into the dbh->prepare. This is the query I cut and pasted into sqlplus just for accuracy. All interpolation is done correctly it looks like. The $retcode should be accurate...there is no point in replacing the WTF because that is never printed. The execute works, and the die never occurs. It simply think there are no rows to return. In sqlplus, over 1200 are returned. The $l resolves to two capital letters in the final run, printed just before the prepare statement. I tried messing with all that.
  • Comment on Re^2: Query works in sqlplus but not DBI

Replies are listed 'Best First'.
Re^3: Query works in sqlplus but not DBI
by moritz (Cardinal) on Feb 29, 2008 at 14:42 UTC
    How do you try to determine the number of rows that DBI returned?

    The DBI manpage says

    A successful "execute" always returns true regardless of the number of rows affected, even if it’s zero
    ...
    For "SELECT" statements, execute simply "starts" the query within the database engine. Use one of the fetch methods to retrieve the data after calling "execute". The "execute" method does not return the number of rows that will be returned by the query (because most databases can’t tell in advance), it simply returns a true value.
      The return value is "0E0" which means zero but true, but only for non-select queries!!! That's my mistake. For a select query it doesn't mean that. The problem was in a binding later!! Thank you so much. I misread the documentation on that.