Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

RE: Re: Importing files with perl::dbi

by httptech (Chaplain)
on Jun 23, 2000 at 15:30 UTC ( #19567=note: print w/replies, xml ) Need Help??

in reply to Re: Importing files with perl::dbi
in thread Importing files with perl::dbi

My solution already uses bind params in the "do" method. I don't think it's necessarily faster to "prepare" and "execute" than to just "do".

However, it is faster to undef $/ and then pass <TEXT> as a scalar than to run "join" on every line and pass the intermediate variable.

Replies are listed 'Best First'.
RE: RE: Re: Importing files with perl::dbi
by johannz (Hermit) on Jun 23, 2000 at 18:59 UTC
    While normally just using a "do" would be correct, in this case since we are talking about a BLOB, using bind with a datatype is safer. By that I mean, when you execute a "do" with bind parameters inline, you are leaving it up the the DBI interface to figure out the datatype. Sometime it will get it right, but there is no guarentee. By using a "bind_param" call with a datatype you are giving the DBI a strong hint as to how to handle the data. To quote again from the Perl DBI book( pg. 154):
    Passing SQL_BLOB as the optional TYPE parameter to bind_param() gives the driver a strong hint that you're binding to a LONG/LOB type. Some drivers don't need the hint but it's always a good idea to include it.
    I keep quoting this book since the authors are Alligator Descartes and Tim Bunce, both of whom have been heavily involved in the design of the DBI interface. I tend to believe what they say about how to use the interface.

    Your second point about undef-ing $/ and passing in <TEXT> I will concede. On examples I tend to be more verbose since it makes debugging easier since you can easily look at the value of a varible. Looking at a filehandle is distinctly harder. :-)
      If you really want to give the driver a hint about what datatype you are passing, you can change the 'undef' in my "do" statement to { TYPE => SQL_BLOB } and it will have the same effect.

      I could have been more verbose on the example, but the original poster did ask for the fastest way. :)

      Update: Now that I look at it, he just said the best way, not the fastest. Heh. Oh well.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://19567]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2023-05-28 03:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found