Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: DBD::ORACLE and date fields

Re: DBD::ORACLE and date fields

From: John D Groenveld <groenvel_at_cse.psu.edu>
Date: 1998/05/29
Message-ID: <6kmle8$f99$1@tholian.cse.psu.edu>#1/1

#!/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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US