#!/usr/bin/env perl
use warnings;
use strict;
use DBI;
my $dbh = DBI->connect( "DBI:CSV:", '', '', { RaiseError => 1 } ) or die DBI->errstr;
my $table = 'my_test_table_1.csv';
$dbh->do( "CREATE TEMP TABLE $table( id INTEGER, name CHAR(64) )" );
my $sth = $dbh->prepare( "INSERT INTO $table ( id, name ) VALUES( ?, ? )" );
$sth->execute( 1, 'Ruth' );
$sth->execute( 2, 'John' );
$sth->execute( 3, 'Nena' );
$sth->execute( 4, 'Mark' );
$sth = $dbh->prepare( "SELECT * FROM $table WHERE id > ? LIMIT ?" );
$sth->execute( 1, 2 );
$sth->dump_results;
# Bad limit clause! at /usr/local/lib/perl5/site_perl/5.20.1/SQL/Statement.pm line 88.
它看起来像一个占位符LIMIT
条款不起作用。
当我使用以下命令时,如何判断 SQL 语句中的某个位置是否支持占位符DBD::CSV司机?
占位符只能用在需要表达式的地方。接下来是什么LIMIT
必须是行计数(而不是表达式),因此它不能是占位符。
#!/usr/bin/perl
use warnings;
use strict;
use DBI qw( );
my $dbh = DBI->connect("DBI:CSV:", undef, undef, {
PrintError => 0, RaiseError => 1,
} );
{
my $sth = $dbh->prepare( "SELECT 1 LIMIT 1" );
$sth->execute();
$sth->finish();
print "ok\n";
}
{
my $sth = $dbh->prepare( "SELECT 1 LIMIT 0+1" );
$sth->execute();
$sth->finish();
print "ok\n";
}
ok
DBD::CSV::db prepare failed: Bad limit clause! at .../SQL/Statement.pm line 88.
[for Statement "SELECT 1 LIMIT 0+1"] at a.pl line 18.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)