Nathan Kurz <[EMAIL PROTECTED]> wrote:
> 
> Inserting blobs works fine if one uses "$sth->bind_param(1, $blob,
> SQL_BLOB)" as in the test.  It does not work if one merely uses
> "$sth->execute($blob)".  While I can see that this might be behaviour
> as designed, it temporarily stumped me when I first starting using it,
> and searching the web I found several others stumped by it as well.
> The poster to the list presumably was having the same problem.
> 
> Looking now at the DBI documentation, I see that values bound using
> execute are 'usually treated as "SQL_VARCHAR" types unless the driver
> can determine the correct type (which is rare)'.  Because it is simple
> to scan the string for NUL's, I guess I consider this one of those
> rare cases where the driver can just 'do the right thing'. 
> 

I know nothing about Perl internals and precious little about the
language itself, so I'm guessing here.  But surely the sqlite driver
must be able to query a perl variable to figure out what datatype
it is currently holding, no?  And with that information, it can 
use whichever sqlite3_bind function is appropriate for that datatype.

So in the example of $sth->execute($blob), if $blob contains an
integer, use sqlite3_bind_int64(), or if $blob contains a string
use sqlite3_bind_text(), or if $blob contains a blob, then use
sqlite3_bind_blob(), and so forth.

Is there something about perl internals that prevents the above
from working?

--
D. Richard Hipp <[EMAIL PROTECTED]>

Reply via email to