[DBD-SQLite] substr w/ two parameters

kenichi ishigaki kishigaki at gmail.com
Sat Feb 12 01:54:51 GMT 2011


Hi,

the following test script works for me on debian, centos, and windows.
Please make sure your DBD::SQLite is compiled with the bundled library.
I'm afraid that your DBD::SQLite is possibly compiled with an older version
of system sqlite.

------------------------
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use Test::More tests => 4;

my $dbh = DBI->connect('dbi:SQLite::memory:');
cmp_ok $DBD::SQLite::VERSION, '>', 1.14, "DBD::SQLite $DBD::SQLite::VERSION";
cmp_ok $dbh->{sqlite_version}, 'ge', "3.6", "Compiled with
$dbh->{sqlite_version}";

$dbh->do('create table foo (text)');
$dbh->do('insert into foo values (?)', undef, "works for me?");
is $dbh->selectrow_array('select substr(text,5) from foo') => 's for me?';
is $dbh->selectrow_array('select substr(text,5,2) from foo') => 's ';
------------------------

HTH,

Kenichi

2011/2/12 Jesse Erdmann <jerdmann at umn.edu>:
> All,
>
> Is there a quick fix to allow substr to be called with two parameters
> instead of three?  Sometime in 3.5 the official SQLite distribution
> made the third parameter optional and it looks like there is code
> within the sqlite3.c that makes queries using that form of the
> function.  However, when I execute a SQL statement in my Perl code
> using either DBD::SQLite 1.31 or 1.32.1 I get an error saying prepare
> failed and that substr was being called with the wrong number of
> arguments.
>
> Using the same query in the sqlite3 command line utility executes
> appropriately.  Thanks!
>
> --
> Jesse Erdmann
> Bioinformatics Analyst
> Masonic Cancer Center
> University of Minnesota
> jerdmann at umn.edu
> 612-626-3123
>
> jesse at jesseerdmann.com
> Twitter: http://twitter.com/jesseerdmann
>
> _______________________________________________
> DBD-SQLite mailing list
> DBD-SQLite at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbd-sqlite
>



More information about the DBD-SQLite mailing list