File: joetest4.pl

package info (click to toggle)
libdbd-odbc-perl 1.13-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 544 kB
  • ctags: 287
  • sloc: perl: 3,395; ansic: 3,236; makefile: 55
file content (30 lines) | stat: -rwxr-xr-x 790 bytes parent folder | download | duplicates (3)
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
28
29
30
#!perl -w
# $Id: joetest4.pl 93 2004-02-19 19:28:16Z jurl $

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 (d DATETIME)");};

if (-e "dbitrace.log") {
   unlink("dbitrace.log");
}
$dbh->trace(9,"dbitrace.log");
my $sth = $dbh->prepare ("INSERT INTO table1 (d) VALUES (?)");
$sth->bind_param (1, undef, SQL_TYPE_TIMESTAMP);

#$sth->bind_param (1, "2002-07-12 05:08:37.350", SQL_TYPE_TIMESTAMP);
$sth->execute("2002-07-12 05:08:37.350");
#$sth->bind_param (1, undef, SQL_TYPE_TIMESTAMP);
$sth->execute(undef);

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