----- Original Message -----
From: "Eko Budiharto" <[EMAIL PROTECTED]>
To: <[email protected]>; <[EMAIL PROTECTED]>
Sent: Wednesday, March 22, 2006 4:28 AM
Subject: accessing DBF file
Hi,
I have a DBF file and like to access it. I already write a script and got
an error message, "
"Can't use string ("01010005") as an ARRAY ref while "strict refs" in use
at migr asi2.pl line 19.
and my script is:
use strict;
use DBI;
my ( $CUST, $NAMA, $AL, $AL2, $TLP, $PERSO, $NPWP, $TERM, $LIMIT, $PKP,
$WIL, $KLINK, $KODE_CABANG, $AL3, $SLM, $VLT, $KDHARGA, $AL_KIRIM1,
$AL_KIRIM2, $AL_KIRIM3, $DISC_NOTA, $NDISC_NOTA, $DISC_FILT, $IKUTPROGSB )
= "";
my $dbh = DBI->connect("DBI:XBase:c:\/temp") or die $DBI::errstr;
my $sth = $dbh->prepare("select * from customer") or die $dbh->errstr();
$sth->execute();
my $ref = $sth->fetchrow_arrayref();
foreach my $row (@$ref) {
my ( $CUST, $NAMA, $AL, $AL2, $TLP, $PERSO, $NPWP, $TERM, $LIMIT, $PKP,
$WIL, $KLINK, $KODE_CABANG, $AL3, $SLM, $VLT, $KDHARGA, $AL_KIRIM1,
$AL_KIRIM2, $AL_KIRIM3, $DISC_NOTA, $NDISC_NOTA, $DISC_FILT, $IKUTPROGSB )
= @$row; }
$dbh->disconnect();
do you mind anyone can tell me what the error means and how I can fix it?
Is many ways how to get data from database but I preffer this way
use strict;
use DBI;
my ( $CUST, $NAMA, $AL, $AL2, $TLP, $PERSO, $NPWP, $TERM, $LIMIT, $PKP,
$WIL, $KLINK, $KODE_CABANG, $AL3, $SLM, $VLT, $KDHARGA, $AL_KIRIM1,
$AL_KIRIM2, $AL_KIRIM3, $DISC_NOTA, $NDISC_NOTA, $DISC_FILT, $IKUTPROGSB );
my $dbh = DBI->connect("DBI:XBase:c:\/temp") or die $DBI::errstr;
my $sth = $dbh->prepare("select cuist, nama, al, al2, tlp, perso, npwp,
term, limit, pkp,wil, klink,
kode_cabang, al3, slm, vlt, kdharga, al_kirim1, al_kirim2, al_kirim3,
disc_nota,
ndisc_nota, disc_filt, ikutprogsb from customer") or die $dbh->errstr();
$sth->execute();
$sth->bind_columns(\ ( $CUST, $NAMA, $AL, $AL2, $TLP, $PERSO, $NPWP, $TERM,
$LIMIT, $PKP, $WIL, $KLINK, $KODE_CABANG, $AL3, $SLM, $VLT, $KDHARGA,
$AL_KIRIM1, $AL_KIRIM2, $AL_KIRIM3, $DISC_NOTA, $NDISC_NOTA, $DISC_FILT,
$IKUTPROGSB ));
print "<table>";
while($sth->fetch) {
print "<tr><td>$CUST</td><td>$NAMA</td><td>$AL</td><td>$AL2</td>";
# ... and next field as you wish
}
print "</table>\n";
Petr Vileta, Czech republic
(My server reject all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs