Re: perl date
- From: samuel_zheng@xxxxxxxxxxxxx (Samuel_Zheng)
- Date: Wed, 29 Aug 2007 05:30:08 -0400
Hi Nelson,
Thanks for the codes. Please forgive my ignoracne, but how to update a date field in dbf ? thanks again.
Samuel
----- Original Message ----- From: "Nelson, Erick [HDS]" <Erick.Nelson@xxxxxxxxxxxx>
To: "Samuel_Zheng" <samuel_zheng@xxxxxxxxxxxxx>
Sent: Tuesday, August 28, 2007 6:43 PM
Subject: RE: perl date
use strict;
use warnings;
use DBI;
use DBD::XBase;
use DBU;
my $xbase_dbh = DBI->connect("DBI:XBase:.", undef, undef, {RaiseError =>
1});
my $oracle_dbh = DBI->connect(DBU::connect('mwh'));
my $create_table = <<EOT;
create table sample (
id int,
dt date
)
EOT
unlink 'sample.dbf';
$xbase_dbh->do($create_table);
my $sel = "select 1, to_char(sysdate,'YYYYMMDD') dt from dual";
my $sel_csr = $oracle_dbh->prepare($sel);
my $ins = "insert into sample (id, dt) values (?,?)";
my $ins_csr = $xbase_dbh->prepare($ins);
$sel_csr->execute();
while (my ($id, $dt) = $sel_csr->fetchrow_array()) {
$ins_csr->execute($id, $dt);
}
$xbase_dbh->disconnect();
$oracle_dbh->disconnect();
-----Original Message-----
From: Samuel_Zheng [mailto:samuel_zheng@xxxxxxxxxxxxx]
Sent: Tuesday, August 28, 2007 3:30 PM
To: Nelson, Erick [HDS]; dbi-users@xxxxxxxx
Subject: Re: perl date
Thank you Nelson for your response. Please cut and paste your codes and
so I
can try them, or how can I get YYYY
MM and DD? What is the function to convert a string to a numeric? Do I
need
this function? Thank you for the help!
----- Original Message ----- From: "Nelson, Erick [HDS]" <Erick.Nelson@xxxxxxxxxxxx>
To: "Samuel_Zheng" <samuel_zheng@xxxxxxxxxxxxx>; <dbi-users@xxxxxxxx>
Sent: Monday, August 27, 2007 11:51 AM
Subject: RE: perl date
I've created dbf files using DBD::XBase a few times.
To get dates to insert correctly I had to have the date in YYYYMMDD
format.
DBD::Xbase writes dbase 4 files.
If Clipper is old enough that it is using dbase 3 files the answer might
be different.
-----Original Message-----
From: Samuel_Zheng [mailto:samuel_zheng@xxxxxxxxxxxxx]
Sent: Monday, August 27, 2007 8:45 AM
To: dbi-users@xxxxxxxx
Subject: perl date
Hi,
I am using ODBC to convert an old clipper application to a web based
application and I came across something seems simple but it's not.
how can I save a date from perl to a date field in dbf file? can a perl
expert helps out someone who is novice in perl like me? your help would
be very much appreciated! Thanks.
Samuel
__________ NOD32 2489 (20070828) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32.com.hk
__________ NOD32 2489 (20070828) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32.com.hk
.
- Prev by Date: Number of row fields inconsistent with NUM_OF_FIELDS, NUM_OF_FIELDS updated
- Next by Date: DBI:Sybase connect error
- Previous by thread: RE: DBI::Informix and DBD::Informix
- Next by thread: Re: perl date
- Index(es):
Relevant Pages
|
|