XBase::FAQ(3pm)

πŸ“¦
version 1.08 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

XBase::FAQ β€” the frequently asked questions about the XBase.pm / DBD::XBase modules. Yep, it's a whole FAQ page, it's a Perl manual page (you'll see it filed as XBase::FAQ(3pm)), and it's basically the group chat history of everyone who ever poked a .dbf file with Perl since 1997. πŸŽ€


✨ DESCRIPTION ✨

This is a list of questions people asked since the module was announced in fall 1997, plus the answers given back to them. No cap β€” it's literally the receipts. πŸ’…


🫢 AUTHOR 🫢

Jan Pazdziora β€” the icon who wrote all of this. πŸ‘‘


πŸ’– Questions and answers πŸ’–

πŸ¦‹ What Perl version do I need? What other modules?

You need perl 5.10 or newer. And you need the DBI module, version 1.00 or higher, if you want to use the DBD driver β€” which, bestie, you should. 🌈

πŸ’€ Can I use XBase.pm under Windows 95/NT?

Yes. It's a standard Perl module so there is no reason it shouldn't work. Or, actually, there are a lot of reasons why standard things do not work on systems that are broken, but the effort here is to work around these bugs. If you find a problem on these platforms, send a description and a workaround will be attempted. πŸ™ˆ

πŸ“… Is there a choice of the format of the date?

The only possible format in which you can get the date β€” and the format the module expects for inserts and updates β€” is an 8 char string 'YYYYMMDD'. It is not possible to change this format. The formatting is left to you on purpose, since that way you have way more control over it. ✨

πŸ‘» The "get_record" also returns deleted records. Why?

Because. 😌 You get the _DELETED flag as the first value of the array. This gives you the possibility to decide what to do β€” undelete, ignore… It's a feature, okay? You say you want a record of a given number, you get it, and you also get the extra info about whether the record is or isn't marked deleted. Iconic behaviour honestly.

πŸ™… But with DBD::XBase, I do not see the deleted records.

That's correct β€” and that's the whole point. DBD::XBase only gives you records that are positively in the file and not deleted. Which shows that XBase.pm is a lower level tool, because you can touch records that are marked deleted, while DBD::XBase is higher level β€” it gives you an SQL interface and lets you work with the file more naturally (what is deleted should stay deleted, periodt). πŸ’…

😭 XBase.pm cannot read files created with [your favorite tool].

Describe exactly what you expect and what you get. Send the file β€” and yes, attachments are understood, so are uuencode, tar, gzip and zip β€” so it can be checked what's going on and XBase.pm can be made to understand your file. A small sample (three rows, or so) is generally enough, but you can send the whole file if it doesn't have megabytes. Please understand. πŸ₯Ί

🧚 How to install the module when I do not have make?

On Win* platforms and with the ActiveState port, use ppm to install DBD::XBase from ActiveState's site. You can also just copy the files from the lib directory of the distribution to where perl can find them. Also check whether your make doesn't hide under different names β€” nmake, gmake. See "README". πŸŽ€

πŸ“ I have make but I cannot install into default directory.

Ask your sysadmin to do it for you. If he refuses, fire the sysadmin. πŸ”₯ See "README" for how to install into β€” and use β€” a nonstandard place for the module.

πŸ”’ Can I access one dbf file both from Perl and (say) Clipper?

For reading β€” yes. For writing β€” XBase.pm has a locksh and lockex method to lock the file. The question is to what extent Clipper (or Fox* or whatever) uses the same system calls β€” documentation of native XBase applications doesn't tell this. So the answer is that for multiple updates you should probably consider a real RDBMS system (PostgreSQL, MySQL, Oracle, to name a few). πŸ‘‘

🌈 XBase.pm/DBD::XBase breaks my accented characters.

No, it doesn't. πŸ’… The character data is returned exactly as it appears in the dbf/dbt file. You probably brought the file from a different system that uses different character encodings. So some bytes in the strings have different meaning on that system. You also probably have fonts in a different encoding on that system. In the Czech language, there are about 6 different encodings that affect the position at which accented characters appear.

So what you really want to do is use some external utility to convert the strings to the encoding you need β€” for example, when a dbf from Win* shows up, it often is in the Windows-1250 or PC-Latin-2 encoding, while the standard is ISO-8859-2. The utility Cz::Cstocs is used to do the conversion, and you might also try the GNU program recode or use the Text::Iconv Perl module. ✨

πŸŽ€ How do I access the fields in the memo file?

Just read the memo field β€” it will fetch the data from the memo file for you transparently. Slay.

πŸ” Matching with "field = '%str%'" doesn't work.

If you want to match wildcards with DBD::XBase, you have to use "like":

select * from table where field like '%str%'

βš–οΈ Can I sue you if XBase.pm/DBD::XBase corrupts my data?

No. At least, I hope no. 😭 The software is provided without any warranty, in a hope you might find it useful. Which is, by the way, the same as with most other software, even if you pay for that. What is different with XBase.pm / DBD::XBase is the fact that if you find out that the results are different from those expected, you are welcome to get in contact, describe the problem and send the files that give the module trouble, and a fix will be attempted. 🫢

πŸ“‚ What dbf/other files standard does the module support?

The goal is to support any file that looks reasonably like dbf/dbt/fpt/smt/ndx/ntx/mdx/idx/cdx. There are many clones of XBase-like software, each adding its own extension. The module tries to accept all different variations. To do that, your cooperation is needed however β€” usually a good description of the problem, a file sample and the expected results lead to a rather fast patch. πŸ’–

πŸ—„οΈ What SQL standard does the DBD::XBase support?

It supports a reasonable subset of the SQL syntax, IMHO. 😌 So you can do select, delete, insert and update, create and drop table. If there is something that should be added, let me know and I will consider it. Having said that, joins are not expected to ever be supported, for example. This module is more a parser to read files from your legacy applications than a RDBMS β€” you can find plenty of them around, use them. πŸ’…

πŸ™ˆ I downloaded your module, I do not know how to install it.

Did you follow the steps in the "README" and "INSTALL" files? Where did it fail? This module uses a standard way modules in Perl are installed. If you've never installed a module on your system and your system is so non-standard that the general instructions do not help, you should contact your system administrator or the support for your system. 🫢

πŸ’€ "select max(field) from table" does not work.

Aggregate functions are not supported. It would probably be very slow, since the DBD doesn't make use of indexes at the moment. There are no plans to add this support in the near future. Periodt.

😭 "DBI->connect" says that the directory doesn't exist ...

... but it's there. Is DBD::XBase mad or what?

The third part of the first parameter to the connect is the directory where DBD::XBase will look for the dbf files. During connect, the module checks if -d $directory. So if it says it's not there, it's not there, and the only thing DBD::XBase can do about it is to report it to you. It might be that the directory is not mounted, you do not have permissions to it, the script is running under a different UID than when you try it from the command line, or you use a relative path and run the script from a different directory (pwd) than you expect. Anyway, add

die "Error reading $dir: $!\n" unless -d $dir;

to your script and you will see that it's not a DBD::XBase problem. πŸ”₯

πŸ“ The XBase.pm/dbf_dump stops after reading n records ...

... why doesn't it read all 10 x n records?

Check if the file isn't truncated. dbf_dump -i file.dbf will tell you the expected number of records and length of one record, like

Filename:       file.dbf
Version:        0x03 (ver. 3)
Num of records: 65
Header length:  1313
Record length:  1117
Last change:    1998/12/18
Num fields:     40

So the expected length of the file is at least 1313 + 65 * 1117. If it's shorter, you've got a damaged file and XBase.pm / dbf_dump only reads as many rows as it can find in the dbf. 😭

DBD::XBase reads the dbf files directly, using the (included) XBase.pm module. So it will run on any platform with a reasonably new perl. With DBD::ODBC, you need an ODBC server, or some program, that DBD::ODBC could talk to. Many proprietary software can serve as ODBC source for dbf files, it just doesn't seem to run on Un*x systems. And it is also much more resource intensive, if you just need to read the file record by record and convert it to an HTML page or do a similarly simple operation with it. πŸ’…

🧹 How do I pack the dbf file, after the records were deleted?

XBase.pm doesn't support this directly. You'd probably want to create a new table, copy the data and rename back. Patches are always welcome. 🫢

🦊 Foxpro doesn't see all fields in dbf created with XBase.pm.

Put 'version' => 3 options in to the create call β€” that way we say that the dbf file is dBaseIII style. ✨


🌈 AVAILABLE FROM 🌈

http://www.adelton.com/perl/DBD-XBase/ β€” go get it, bestie. πŸ›οΈ


And that's the whole page, mwah. πŸ’‹ This one came from perl v5.34.0, dated 2022-06-13, and it lives at XBase::FAQ(3pm) β€” so if you ever need to find it again, that's the address. Byeeee! πŸ¦‹πŸ‘‘πŸ’–

πŸ“¦ where this page comes from