Re: perl date
- From: samuel_zheng@xxxxxxxxxxxxx (Samuel_Zheng)
- Date: Thu, 30 Aug 2007 09:35:23 -0400
I see now the file location should be specify after DBI:XBase:,
not in front of the file name. Thank you.
Samuel
----- Original Message ----- From: "Nelson, Erick [HDS]" <Erick.Nelson@xxxxxxxxxxxx>
To: "Samuel_Zheng" <samuel_zheng@xxxxxxxxxxxxx>
Sent: Wednesday, August 29, 2007 11:53 AM
Subject: RE: perl date
erickn@isfe:/home/erickn> perl test.pl
1 = 20071202
erickn@isfe:/home/erickn> cat test.pl
use strict;
use warnings;
use DBI;
use DBD::XBase;
my $xbase_dbh = DBI->connect("DBI:XBase:.", undef, undef, {RaiseError =>
1});
my $upd = "update sample set dt = ? where id = ?";
my $upd_csr = $xbase_dbh->prepare($upd);
my $sel = "select id, dt from sample";
my $sel_csr = $xbase_dbh->prepare($sel);
$upd_csr->execute('20071202', 1);
$sel_csr->execute();
while (my ($id, $dt) = $sel_csr->fetchrow_array()) {
print "$id = $dt\n";
}
$xbase_dbh->disconnect();
-----Original Message-----
From: Samuel_Zheng [mailto:samuel_zheng@xxxxxxxxxxxxx] Sent: Wednesday, August 29, 2007 2:30 AM
To: Nelson, Erick [HDS]; dbi-users@xxxxxxxx
Subject: Re: perl date
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
__________ NOD32 2490 (20070829) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32.com.hk
.
- Prev by Date: Re: perl date
- Next by Date: dynamic lib ignored even after "found" in "install_driver(Oracle) failed: Can't load..." cgi problem
- Previous by thread: Re: perl date
- Next by thread: Re: DBI::Informix and DBD::Informix
- Index(es):
Relevant Pages
|
|