On Tue Nov 01, 2016 at 03:15:43PM +0000, Simon Slavin wrote: > > On 1 Nov 2016, at 3:14pm, Rob Willett <rob.sql...@robertwillett.com> > wrote: > > > We use the Perl DBD module all the time. What I would expect to see > > is [... good stuff ...] > > Ah, thanks for the explanation. I always had trouble understanding > Perl's approach to anything. Hope the OP's problem gets solved.
For trivial value types (e.g. obvious strings and/or numbers) Rob's explaination is usually all one needs to know: my $sth = $dbh->prepare('statement with ? and ?'); $sth->execute("some","value"); One can even combine prepare, execute & fetch all in one go: my @array = $dbh->selectrow_array($statement, \%attr, @bind_values); Unfortunately I can't always do the above steps due to Perl or DBI or DBD::SQLite making wrong assumptions about the type of the value being bound. If I wanted to store say a phone number string (for example "+417612341234") or a string composed of integers with a leading zero (012) and just pass it in naively it could get converted to a plain number (417612341234 or 12) which is not what I want. So in those cases I have to bind each value separately, specifying the type. [ This is usually more of an issue with databases that are more strongly typed than SQLite. ] my $sth = $db->prepare('statement with ? and ?'); $sth->bind_param(1, '2016-08-01', SQL_DATETIME); $sth->bind_param(1, '012', SQL_VARCHAR); $sth->execute; In fact my code is always doing the bind_param calls individually because I have an abstraction layer that does it that way whether I need it or not. There is probably a performance hit but it is somewhere below the noise floor. -- Mark Lawrence _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users