File: testundef3.pl

package info (click to toggle)
libdbd-odbc-perl 1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,012 kB
  • ctags: 398
  • sloc: perl: 6,314; ansic: 4,875; makefile: 29; sql: 8
file content (27 lines) | stat: -rwxr-xr-x 713 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!perl -w
# $Id: testundef3.pl 11680 2008-08-28 08:23:27Z mjevans $

use strict;
use DBI qw(:sql_types);
my $dbh=DBI->connect() or die "Can't connect";

eval {$dbh->do("DROP TABLE table1");};
eval {$dbh->do("CREATE TABLE table1 (str VARCHAR(10))");};

unlink("dbitrace.log") if (-e "dbitrace.log") ;
$dbh->trace(8, "dbitrace.log");
my $sth = $dbh->prepare ("INSERT INTO table1 (str) VALUES (?)");
$sth->bind_param (1, undef, SQL_VARCHAR);
$sth->execute();
$sth->bind_param (1, "abcde", SQL_VARCHAR);
$sth->execute();

my $sth2 = $dbh->prepare("select * from table1");
$sth2->execute;
my @row;
my $i = 0;
while (@row = $sth2->fetchrow_array) {
   $i++;
   print "$i: ", join(', ', @row), "\n";
}
$dbh->disconnect;