tags:

views:

53

answers:

2

HI am using SQLite DB and whenever I try to bind the values of parameter into the statement I am getting an error.

Here's the piece of code:

my $sth = $dbh->prepare("SELECT UserId,UserName,CardNo,GroupId,Role,VerifyType FROM
    UsersList limit ?,? "); 
$sth->bind_param(1, undef,SQL_VARCHAR);
$sth->bind_param(2, undef,SQL_VARCHAR);
$sth->execute($page,$results_per_page);

Here's the error:

ERROR: DBD::SQLite::st execute failed: datatype mismatch at line 68.

Can anybody Please help me out and let me know what datatype am I supposed to put in place of SQL_VARCHAR?

+1  A: 

Limits are integers and not text, so I'd guess SQL_INTEGER might be a thing to try first?

Donal Fellows
I TRIED using SQL_INTEGER Also but the same error exists,i even used use DBI qw(:sql_types); but nothing is working ;-(
SUSH
+4  A: 

Looks like you are using bind_param() wrong. Take a look at this example:

use DBI qw(:sql_types);  # Don't forget this

my $sth = $dbh->prepare(q{
    SELECT bar FROM foo GROUP BY bar HAVING count(*) > ?;
});
$sth->bind_param(1, 5, SQL_INTEGER);
$sth->execute();

i.e.: no arguments to execute() and the value goes in the bind_param() call.

Øyvind Skaar
Thanks a Lot ,That works Perfectly fine.;-)
SUSH