List Info

Thread: accessing DBF file




accessing DBF file
user name
2006-03-22 03:28:26
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, $KLIN! K, $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?
 
What I would like to do is access the DBF file and print each field to the a HTML page.
 
I am looking forward to a favorable reply from you. Thank you.
 
 
Regards,
Eko Budiharto
 


Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
accessing DBF file
user name
2006-03-22 05:57:25




>my $ref = $sth->fetchrow_arrayref();

>foreach my $row ($ref) {

may be you want use just like this

while (my $row = $sth->fetchrow_arrayref() )


OR you can use  'fetchall_arrayref' instead of
'fetchrow_arrayref'.


'fetchrow_arrayref()' fetches the next row of data and
returns a reference
to an array holding the field values.
'fetchall_arrayref()' returns a reference to an array that
contains one
reference per row.





Confidentiality Notice: This transmittal is a confidential
communication.  If you are not the intended recipient, you
are hereby notified that you have received this transmittal
in error and that any review, dissemination, distribution or
copying of this transmittal is strictly prohibited. If you
have received this communication in error, please notify
this office immediately by reply and immediately delete this
message and all of its attachments, if any.

_______________________________________________
ActivePerl mailing list
ActivePerllistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )