6
use DBI::Const::GetInfoType;
13
use vars qw($table $test_dsn $test_user $test_password);
18
eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
19
{ RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
21
plan skip_all => "ERROR: $@. Can't continue test";
25
ok(defined $dbh, "Connected to database");
27
ok($dbh->do("DROP TABLE IF EXISTS $table"), "making slate clean");
29
ok($dbh->do("CREATE TABLE $table (id INT(4), name VARCHAR(64))"), "creating table");
31
ok(($sth = $dbh->prepare("INSERT INTO $table VALUES (?,?)")));
33
print "PERL testing insertion of values from previous prepare of insert statement:\n";
34
for (my $i = 0 ; $i < 100; $i++) {
35
my @chars = grep !/[0O1Iil]/, 0..9, 'A'..'Z', 'a'..'z';
36
my $random_chars = join '', map { $chars[rand @chars] } 0 .. 16;
37
# save these values for later testing
38
$testInsertVals->{$i} = $random_chars;
39
ok(($rows = $sth->execute($i, $random_chars)));
41
print "PERL rows : " . $rows . "\n";
43
print "PERL testing prepare of select statement with LIMIT placeholders:\n";
44
ok($sth = $dbh->prepare("SELECT * FROM $table LIMIT ?, ?"));
46
print "PERL testing exec of bind vars for LIMIT\n";
47
ok($sth->execute(20, 50));
49
my ($row, $errstr, $array_ref);
50
ok( (defined($array_ref = $sth->fetchall_arrayref) &&
51
(!defined($errstr = $sth->errstr) || $sth->errstr eq '')));
53
ok(@$array_ref == 50);
57
ok($dbh->do("DROP TABLE $table"));