1XBase::FAQ(3) User Contributed Perl Documentation XBase::FAQ(3)
2
3
4
6 XBase::FAQ - Frequently asked questions about the XBase.pm/DBD::XBase
7 modules
8
10 This is a list of questions people asked since the module has been
11 announced in fall 1997, and my answers to them.
12
14 Jan Pazdziora
15
17 What Perl version do I need? What other modules?
18 You need perl 5.10 or newer. You need DBI module version 1.00 or
19 higher, if you want to use the DBD driver (which you should).
20
21 Can I use XBase.pm under Windows 95/NT?
22 Yes. It's a standard Perl module so there is no reason it shouldn't.
23 Or, actually, there are a lot of reasons why standard thing do not
24 work on systems that are broken, but I'm trying hard to workaround
25 these bugs. If you find a problem on these platform, send me a
26 description and I'll try to find yet another workaround.
27
28 Is there a choice of the format of the date?
29 The only possible format in which you can get the date and that the
30 module expect for inserts and updates is a 8 char string 'YYYYMMDD'.
31 It is not possible to change this format. I prefer to do the
32 formating myself since you have more control over it.
33
34 The "get_record" also returns deleted records. Why?
35 Because. You get the _DELETED flag as the first value of the array.
36 This gives you a possibility to decide what to do -- undelete,
37 ignore... It's a feature -- you say you want a record of given
38 number, you get it and get additional information, if the record is
39 or isn't marked deleted.
40
41 But with DBD::XBase, I do not see the deleted records.
42 That's correct: DBD::XBase only gives you records that are positively
43 in the file and not deleted. Which shows that XBase.pm is a lower
44 level tool because you can touch records that are marked deleted,
45 while DBD::XBase is higher level -- it gives you SQL interface and
46 let's you work with the file more naturaly (what is deleted should
47 stay deleted).
48
49 XBase.pm cannot read files created with [your favorite tool].
50 Describe exactly, what you expect and what you get. Send me the file
51 (I understand attachments, uuencode, tar, gzip and zip) so that I can
52 check what it going on and make XBase.pm undestand your file. A
53 small sample (three rows, or so) are generally enough but you can
54 send the whole file if it doesn't have megabytes. Please understand
55
56 How to install the module when I do not have make?
57 On Win* platform and with ActiveState port, use ppm to install
58 DBD::XBase from ActiveState's site. You can also just copy the files
59 from the lib directory of the distribution to where perl can find
60 them. Also check whether your make doesn't hide under different names
61 (nmake, gmake). See "README".
62
63 I have make but I cannot install into default directory.
64 Ask your sysadmin to do it for your. If he refuses, fire the
65 sysadmin. See "README" for how to install into and use nonstandard
66 place for the module.
67
68 Can I access one dbf file both from Perl and (say) Clipper?
69 For reading -- yes. For writing -- XBase.pm has a locksh and lockex
70 method to lock the file. The question is to what extend Clipper (or
71 Fox* or whatever) uses the same system calls, documentation of native
72 XBase applications doesn't tell this. So the answer is that for
73 multiple updates you should probably consider real RDBMS system
74 (PostgreSQL, MySQL, Oracle, to name a few).
75
76 XBase.pm/DBD::XBase breaks my accented characters.
77 No, it doesn't. The character data is returned exactly as it appears
78 in the dbf/dbt file. You probably brought the file from different
79 system that uses differend character encodings. So some bytes in the
80 strings have different meaning on that system. You also probably have
81 fonts in different encoding on that system. In the Czech language, we
82 have about 6 different encoding that affect possition at which
83 accented characters appear.
84
85 So what you really want to do is to use some external utility to
86 convert the strings to encoding you need -- for example, when I bring
87 the dbf from Win*, it often is in the Windows-1250 or PC-Latin-2
88 encoding, while the standard is ISO-8859-2. I use my utility
89 Cz::Cstocs to do the conversion, you maight also try GNU program
90 recode or use Text::Iconv Perl module.
91
92 How do I access the fields in the memo file?
93 Just read the memo field, it will fetch the data from the memo file
94 for you transparently.
95
96 Matching with "field = '%str%'" doesn't work.
97 If you want to match wildcards with DBD::XBase, you have to use
98 "like":
99
100 select * from table where field like '%str%'
101
102 Can I sue you if XBase.pm/DBD::XBase corrupts my data?
103 No. At least, I hope no. The software is provided without any
104 warranty, in a hope you might find is usefull. Which is by the way
105 the same as with most other software, even if you pay for that. What
106 is different with XBase.pm/DBD::XBase is the fact that if you find
107 out that the results are different from those expected, you are
108 welcome to contact me, describe the problem and send me the files
109 that give troubles to the module, and I'll try to find fix the
110 module.
111
112 What dbf/other files standard does the module support?
113 I try to support any file that looks reasonably as
114 dbf/dbt/fpt/smt/ndx/ntx/mdx/idx/cdx. There are many clones of XBase-
115 like software, each adding its own extension. The module tries to
116 accept all different variations. To do that, I need your cooperation
117 however -- usually good description of the problem, file sample and
118 expected results lead to rather fast patch.
119
120 What SQL standard does the DBD::XBase support?
121 If supports a reasonable subset of the SQL syntax, IMHO. So you can
122 do select, delete, insert and update, create and drop table. If there
123 is something that should be added, let me know and I will consider
124 it. Having said that, I do not expect to ever support joins, for
125 example. This module is more a parser to read files from your legacy
126 applications that a RDBMS -- you can find plenty of them around --
127 use them.
128
129 I downloaded you module I do not know how to install it.
130 Did you follow the steps in the "README" and "INSTALL" files? Where
131 did it fail? This module uses a standard way modules in Perl are
132 installed. If you've never installed a module on your system and your
133 system is so non-standard that the general instruction do not help,
134 you should contact your system administrator or the support for your
135 system.
136
137 "select max(field) from table" does not work.
138 Aggregate functions are not supported. It would probably be very
139 slow, since the DBD doesn't make use of indexes at the moment. I do
140 not have plans to add this support in some near future.
141
142 "DBI->connect" says that the directory doesn't exist ...
143 ... but it's there. Is DBD::XBase mad or what?
144
145 The third part of the first parameter to the connect is the directory
146 where DBD::XBase will look for the dbf files. During connect, the
147 module checks "if -d $directory". So if it says it's not there, it's
148 not there and the only thing DBD::XBase can do about it is to report
149 it to you. It might be that the directory is not mounted, you do not
150 have permissions to it, the script is running under different UID
151 than when you try it from command line, or you use relative patch and
152 run the script from a different directory (pwd) than you expect.
153 Anyway, add
154
155 die "Error reading $dir: $!\n" unless -d $dir;
156
157 to your script and you will see that it's not DBD::XBase problem.
158
159 The XBase.pm/dbfdump.pl stops after reading n records ...
160 ... why doesn't it read all 10 x n records?
161
162 Check if the file isn't truncated. "dbfdump.pl -i file.dbf" will tell
163 you the expected number of records and length of one record, like
164
165 Filename: file.dbf
166 Version: 0x03 (ver. 3)
167 Num of records: 65
168 Header length: 1313
169 Record length: 1117
170 Last change: 1998/12/18
171 Num fields: 40
172
173 So the expected length of the file is at least 1313 + 65 * 1117. If
174 it's shorter, you've got damaged file and XBase.pm/dbfdump.pl only
175 reads as much rows as it can find in the dbf.
176
177 How is this DBD::XBase related to DBD::ODBC?
178 DBD::XBase reads the dbf files directly, using the (included)
179 XBase.pm module. So it will run on any platform with reasonable new
180 perl. With DBD::ODBC, you need an ODBC server, or some program, that
181 DBD::ODBC could talk to. Many proprietary software can serve as ODBC
182 source for dbf files, it just doesn't seem to run on Un*x systems.
183 And is also much more resource intensive, if you just need to read
184 the file record by record and convert it to HTML page or do similary
185 simple operation with it.
186
187 How do I pack the dbf file, after the records were deleted?
188 XBase.pm doesn't support this directly. You'd probably want to create
189 new table, copy the data and rename back. Patches are always welcome.
190
191 Foxpro doesn't see all fields in dbf created with XBase.pm.
192 Put 'version' => 3 options in to the create call -- that way we say
193 that the dbf file is dBaseIII style.
194
196 http://www.adelton.com/perl/DBD-XBase/
197
198
199
200perl v5.32.1 2021-01-27 XBase::FAQ(3)