in reply to Re^2: Can not get the same output from $dbh->do and $dbh->prepare
in thread Can not get the same output from $dbh->do and $dbh->prepare

The link just worked for me, but then again, CPAN has been a bit flaky lately.

That said, here is the wording from the relevant section:

do $rows = $dbh->do($statement) or die $dbh->errstr; $rows = $dbh->do($statement, \%attr) or die $dbh->errstr; $rows = $dbh->do($statement, \%attr, @bind_values) or die ... Prepare and execute a single statement. Returns the number of rows aff +ected or undef on error. A return value of -1 means the number of row +s is not known, not applicable, or not available. This method is typically most useful for non-SELECT statements that ei +ther cannot be prepared in advance (due to a limitation of the driver +) or do not need to be executed repeatedly. It should not be used for + SELECT statements because it does not return a statement handle (so +you can't fetch any data).
The key to using do is that it can only return the number of row affected by an operation. This makes it ideal for INSERT, UPDATE and DELETE, but it simply can't do what you want when it comes to a SELECT statement.

Sorry if the first post came across as a bit harsh, I should have put a smiley in there somewhere. Now that you beginning your endeavor to grok "DBI" you should probably a browser window open to the CPAN docs for it constantly. Hell, I still go back and check details on calls.

It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

Replies are listed 'Best First'.
Re^4: Can not get the same output from $dbh->do and $dbh->prepare
by thanos1983 (Parson) on May 28, 2014 at 22:34 UTC

    To: boftx

    I want to say sorry to, my message was intended to be offensive, on the contrariwise I appreciate the time of each person who spends to assist beginners like me. To be 100% honest I had to read it twice to understand the meaning of do and prepare, well I guess lately I am pushing my self to much and I need to get some sleep eventually this might give me a more clear point of view.

    Again I ought to say thank you, and my apologies if some how I offended you.

    BR, Thanos

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

      No problems! No offense was taken. I read your reply and thought I probably came off a bit more harsh than I normally do. The people I work with have gotten use to me being a bit of an arrogant prick. :)

      It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.