/usr/share/doc/libdbd-odbc-perl/examples/timetest.pl is in libdbd-odbc-perl 1.52-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/perl -w
# $Id$
use strict;
use DBI qw(:sql_types);
my $dbh=DBI->connect() or die "Can't connect";
$dbh->{RaiseError} = 1;
$dbh->{LongReadLen} = 800;
eval {
$dbh->do("drop table foo");
};
my @types = (SQL_TYPE_TIMESTAMP, SQL_TIMESTAMP);
my $type;
my @row;
foreach $type (@types) {
my $sth = $dbh->func($type, "GetTypeInfo");
if ($sth) {
@row = $sth->fetchrow();
$sth->finish();
last if @row;
} else {
# warn "Unable to get type for type $type\n";
}
}
die "Unable to find a suitable test type for date field\n"
unless @row;
my $dbname = $dbh->get_info(17); # sql_dbms_name
my $datetype = $row[0];
print "Date type = $datetype\n";
$dbh->do("Create table foo (idcol integer not null primary key, dt $datetype)");
my @tests = (
"{ts '1998-05-13 00:01:00'}",
"{ts '1998-05-15 00:01:00.5'}",
"{ts '1998-05-15 00:01:00.210'}",
);
my $test;
my $i = 0;
my $sth = $dbh->prepare("insert into foo (idcol, dt) values (?, ?)");
foreach $test (@tests) {
$sth->execute($i++, $test);
}
$sth = $dbh->prepare("Select idcol, dt from foo order by idcol");
$sth->execute;
while (@row = $sth->fetchrow_array) {
print join(', ', @row), "\n";
}
$dbh->disconnect;
|