in reply to Re: Seemingly Internal DBD-XBase Error
in thread Seemingly Internal DBD-XBase Error

Sorry... I should have posted this before. My code is as follows.

my $dbh = DBI->connect("DBI:XBase:m:\\") or die $DBI::errstr;
my $sth = $dbh->prepare("select custnum FROM cms where order = 1002");
$sth->execute() or die $sth->errstr();

my @data;
my $i = 0;
while (@data = $sth->fetchrow_array()) {
		print "$data$i\n";
		$i++;
}

Here's the code in XBase.pm that's giving the error. Line 337 is

$xbase = new XBase(%opts) or do

	# let's see if we've already opened the table
	my $xbase = $dbh->{'xbase_tables'}->{$table};
	if (not defined $xbase)
		{			# if not, open the table now
		my $filename = $dbh->{'Name'} . '/' . $table;
		my %opts = ('name' => $filename);
		$opts{'ignorememo'} = 1 if $dbh->{'xbase_ignorememo'};
		# try to open the table using XBase.pm
		$xbase = new XBase(%opts) or do
			{
			$sth->DBI::set_err(3, "Table $table not found: "
							. XBase->errstr());
			return;
			};
		$dbh->{'xbase_tables'}->{$table} = $xbase;	
		}
  • Comment on Re: Re: Seemingly Internal DBD-XBase Error

Replies are listed 'Best First'.
Re: Re: Re: Seemingly Internal DBD-XBase Error
by PsychoSpunk (Hermit) on Dec 22, 2000 at 01:58 UTC
    Um... What's this?

    my $dbh = DBI->connect("dbi:XBase: m:\\") ...

    Could it be that you're using the delimiter for the connect string within your directory specification? That's a small hazardous guess, since I haven't used DBD::XBase, but since ':' is the standard delimiter, you may have to find a different manner of specfifying directory.

    Also, after using DBI with Oracle and MS SQL Server, and just recently MySQL, I have to say that DBD:XBase has one of the strangest connect strings I've seen. Try this to get a better understanding of what the connect string is seeing:

    DBI->trace(3); $dbh = DBI->connect("dbi:XBase:m:\\");

    UPDATE: Is it safe to presume that you don't need a user and password for your dbf file? Looking at the trace output immediately below this post, it appears that you get a database handle, but the statement handle is what's creating the error. That's as far down the road as I can take you, young monk, but it may be enough to put it all together.

    ALL HAIL BRAK!!!

      I've changed my connect string and put the table in the same directory as my script as follows.

      my $dbh = DBI->connect("dbi:XBase:/") or die $DBI::errstr;
      
      

      Here's the trace output.

          DBI 1.14-nothread dispatch trace level set to 3
          Note: perl is running without the recommended perl -w option
          -> DBI->connect(dbi:XBase:/, , ****)
          -> DBI->install_driver(XBase) for perl=5.006 pid=1444 ruid=0 euid=0
             install_driver: DBD::XBase loaded (version 0.147)
          New DBI::dr (for DBD::XBase::dr, parent=, id=)
          dbih_setup_handle(DBI::dr=HASH(0x2dbd764)=>DBI::dr=HASH(0x4ec35a8), DBD::XBase::dr, 0,
       Null!)
          dbih_make_com(Null!, DBD::XBase::dr, 172)
          <- install_driver= DBI::dr=HASH(0x2dbd764)
          -> default_user in DBD::_::dr for DBD::XBase::dr (DBI::dr=HASH(0x2dbd764)~0x4ec35a8 un
      def undef HASH(0x1a751c8))
          <- default_user= ( undef undef ) 2 items at DBI.pm line 405.
          -> connect for DBD::XBase::dr (DBI::dr=HASH(0x2dbd764)~0x4ec35a8 '/' undef **** HASH(0
      x1a751c8))
          New DBI::db (for DBD::XBase::db, parent=DBI::dr=HASH(0x4ec35a8), id=)
          dbih_setup_handle(DBI::db=HASH(0x4ec356c)=>DBI::db=HASH(0x4ec3584), DBD::XBase::db, 2d
      c0b78, Null!)
          dbih_make_com(DBI::dr=HASH(0x4ec35a8), DBD::XBase::db, 172)
          <- connect= DBI::db=HASH(0x4ec356c) at DBI.pm line 408.
          -> STORE for DBD::XBase::db (DBI::db=HASH(0x4ec3584)~INNER 'PrintError' 1)
          STORE DBI::db=HASH(0x4ec3584) 'PrintError' => 1
          <- STORE= 1 at DBI.pm line 433.
          -> STORE for DBD::XBase::db (DBI::db=HASH(0x4ec3584)~INNER 'AutoCommit' 1)
          <- STORE= 1 at DBI.pm line 433.
          <- connect= DBI::db=HASH(0x4ec356c)
          -> prepare for DBD::XBase::db (DBI::db=HASH(0x4ec356c)~0x4ec3584 'select custnum FROM
      cms where order = 1002')
          New DBI::st (for DBD::XBase::st, parent=DBI::db=HASH(0x4ec3584), id=)
          dbih_setup_handle(DBI::st=HASH(0x4ec353c)=>DBI::st=HASH(0x4ede9e8), DBD::XBase::st, 4e
      c35d8, Null!)
          dbih_make_com(DBI::db=HASH(0x4ec3584), DBD::XBase::st, 172)
          <- prepare= DBI::st=HASH(0x4ec353c) at smike2.pl line 95.
          -> execute for DBD::XBase::st (DBI::st=HASH(0x4ec353c)~0x4ede9e8)
      Can't locate object method "new" via package "XBase" at C:/Perl/lib/DBD/XBase.pm line 337.
      
          <> DESTROY ignored for outer handle DBI::db=HASH(0x4ec356c) (inner DBI::db=HASH(0x4ec3
      584))
          <> DESTROY ignored for outer handle DBI::st=HASH(0x4ec353c) (inner DBI::st=HASH(0x4ede
      9e8))
          -> DESTROY for DBD::XBase::st (DBI::st=HASH(0x4ede9e8)~INNER)
          <- DESTROY= undef at unknown location!
          -> DESTROY for DBD::XBase::db (DBI::db=HASH(0x4ec3584)~INNER)
          <- DESTROY= undef at unknown location!
          -- DBI::END
          -> disconnect_all for DBD::XBase::dr (DBI::dr=HASH(0x2dbd764)~0x4ec35a8)
          <- disconnect_all= 1 at DBI.pm line 450.
          -> DESTROY in DBD::_::common for DBD::XBase::dr (DBI::dr=HASH(0x4ec35a8)~INNER)
          <- DESTROY= undef during global destruction.
          <> DESTROY for DBI::dr=HASH(0x2dbd764) ignored (inner handle gone)

      I believe it is safe to assume I do not need a password. With XBase, there is no database engine to talk to. DBD-XBase uses the XBase.pm module to directly parse the DBF files. According to the documentation for DBD-XBase, all you have to do is specifiy the directory. The DBD-XBase documentation never mentions user names or passwords.

      I really appreciate your help - Thanks.

Re: Re: Re: Seemingly Internal DBD-XBase Error
by Fastolfe (Vicar) on Dec 22, 2000 at 01:28 UTC
    I'm wondering if the code is assuming its object class is XBase instead of DBD::XBase? Perhaps somebody else that actually has this module can do some "real" debugging? Good luck.