File: testundef3.pl

package info (click to toggle)
libdbd-odbc-perl 1.50-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,392 kB
  • ctags: 496
  • sloc: perl: 8,818; ansic: 6,376; makefile: 33; sql: 8
file content (27 lines) | stat: -rwxr-xr-x 662 bytes parent folder | download | duplicates (6)
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$

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;