Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DBD::ORACLE and date fields
#!/usr/bin/perl -w
use DBI;
use strict;
my $dbh = DBI->connect("dbi:Oracle:", "scott", "tiger", {AutoCommit=>0})
or die "$DBI::err: $DBI::errstr\n";
$dbh->do("DROP TABLE foobar")
or warn "$DBI::err: $DBI::errstr\n";
$dbh->do("CREATE TABLE foobar (foo NUMBER, bar DATE)")
or die "$DBI::err: $DBI::errstr\n";
my $sql = "INSERT INTO foobar VALUES (?, TO_DATE(?, 'YYYYMMDD'))"; my $sth = $dbh->prepare($sql)
or die "$DBI::err: $DBI::errstr\n";
$sth->execute(1,'19991231')
or die "$DBI::err: $DBI::errstr\n";
$dbh->commit
or die "$DBI::err: $DBI::errstr\n";
$sth = $dbh->prepare("SELECT bar FROM foobar WHERE foo=?")
or die "$DBI::err: $DBI::errstr\n";
$sth->execute(1)
or die "$DBI::err: $DBI::errstr\n";
my @row;
while (@row = $sth->fetchrow_array) {
die "$DBI::err: $DBI::errstr\n" if $DBI::err;
print "@row\n";
}
$sth->finish
or die "$DBI::err: $DBI::errstr\n";
$dbh->disconnect
or die "$DBI::err: $DBI::errstr\n"; Received on Fri May 29 1998 - 00:00:00 CDT
![]() |
![]() |