Skip Menu |
 

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 12674
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: Mario.Holbe [...] TU-Ilmenau.DE
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.08
Fixed in: (no value)



Subject: DBD::SQLite ignores parameter bindings
Download (untitled) / with headers
text/plain 1.6k
Hello, trying to insert some string containing numbers only into a sqlite3 DB via DBD::SQLite does always insert an integer. This appears to be a problem if the string starts with zeros. This is what happens with sqlite3 directly (and how it would be okay in the more or less typeless sense of sqlite): Show quoted text
sqlite> CREATE TABLE foo(a varchar(4), x varchar(4), y varchar(4)); sqlite> INSERT INTO foo(a, x, y) VALUES('010A', '010A', '010A'); sqlite> INSERT INTO foo(a, x, y) VALUES('0107', '0107', '0107'); sqlite> INSERT INTO foo(a, x, y) VALUES(0107, 0107, 0107); sqlite> SELECT * FROM foo;
010A|010A|010A 0107|0107|0107 107|107|107 When I try to achieve the same with DBD:SQLite as in the following script fragment... unlink "te.db"; $database = DBI->connect("dbi:SQLite:dbname=te.db", "", "") or die; $database->do("CREATE TABLE foo(a varchar(4), x varchar(4), y varchar(4))") or die; $i = $database->prepare("INSERT INTO foo(a, x, y) VALUES(?, ?, ?)") or die; $i->execute('010A', '010A', '010A'); $i->execute('0107', '0107', '0107'); $i->bind_param(1, '0107', { TYPE => SQL_VARCHAR }); $i->bind_param(2, '0107', { TYPE => SQL_VARCHAR }); $i->bind_param(3, '0107', { TYPE => SQL_VARCHAR }); $i->execute; $i->execute(0107, 0107, 0107); $database->disconnect(); ... the result is different: Show quoted text
sqlite> SELECT * FROM foo;
010A|010A|010A 107|107|107 107|107|107 71|71|71 The last line is okay, since this is due to perls octal-conversion. However, at least one of the both lines in the middle should contain 0107 because of the explicite bind_param() (in fact, IMHO both lines should contain 0107 because of the implicite bind_param() that should have been done with the first execute()). regards Mario
Download (untitled) / with headers
text/plain 397b
On Wed May 04 09:16:31 2005, guest wrote: Show quoted text
> Hello, > > trying to insert some string containing numbers only into a sqlite3 DB > via DBD::SQLite does always insert an integer. This appears to be a > problem if the string starts with zeros.
I was having a similar problem (but mine was inserting strings that looked like '1E7' or '2E2'), and I upgraded to 1.11 and the problem went away.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.