.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "DBD::XBase 3pm" .TH DBD::XBase 3pm "2017-01-21" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBD::XBase \- DBI driver for XBase compatible database files .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& use DBI; \& my $dbh = DBI\->connect("DBI:XBase:/directory/subdir") \& or die $DBI::errstr; \& my $sth = $dbh\->prepare("select MSG from test where ID != 1") \& or die $dbh\->errstr(); \& $sth\->execute() or die $sth\->errstr(); \& \& my @data; \& while (@data = $sth\->fetchrow_array()) \& { ## further processing } \& \& $dbh\->do(\*(Aqupdate table set name = ? where id = 45\*(Aq, {}, \*(Aqkrtek\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1DBI\s0 compliant driver for module XBase. Please refer to \s-1\fIDBI\s0\fR\|(3) documentation for how to actually use the module. In the \fBconnect\fR call, specify the directory containing the dbf files (and other, memo, etc.) as the third part of the connect string. It defaults to the current directory. .PP Note that with dbf, there is no database server that the driver would talk to. This DBD::XBase calls methods from XBase.pm module to read and write the files on the disk directly, so any limitations and features of XBase.pm apply to DBD::XBase as well. DBD::XBase basically adds \s-1SQL, DBI\s0 compliant interface to XBase.pm. .PP The DBD::XBase doesn't make use of index files at the moment. If you really need indexed access, check \fIXBase\fR\|(3) for notes about support for variour index types. .SH "SUPPORTED SQL COMMANDS" .IX Header "SUPPORTED SQL COMMANDS" The \s-1SQL\s0 commands currently supported by DBD::XBase's prepare are: .SS "select" .IX Subsection "select" .Vb 2 \& select fields_or_expressions from table [ where condition ] \& [ order by field ] .Ve .PP Fields_or_expressions is a comma separated list of fields or arithmetic expressions, or a \f(CW\*(C`*\*(C'\fR for all fields from the table. The \&\f(CW\*(C`where\*(C'\fR condition specifies which rows will be returned, you can have arbitrary arithmetic and boolean expression here, compare fields and constants and use \f(CW\*(C`and\*(C'\fR and \f(CW\*(C`or\*(C'\fR. Match using \f(CW\*(C`like\*(C'\fR is also supported. Examples: .PP .Vb 7 \& select * from salaries where name = "Smith" \& select first,last from people where login = "ftp" \& or uid = 1324 \& select id,first_name,last_name from employ \& where last_name like \*(AqKi%\*(Aq order by last_name \& select id + 1, substr(name, 1, 10) from employ where age > 65 \& select id, name from employ where id = ? .Ve .PP You can use bind parameters in the where clause, as the last example shows. The actual value has to be supplied via bind_param or in the call to execute or do, see \s-1\fIDBI\s0\fR\|(3) for details. To check for \s-1NULL\s0 values in the \f(CW\*(C`where\*(C'\fR expression, use \f(CW\*(C`id is null\*(C'\fR and \f(CW\*(C`id is not null\*(C'\fR, not \f(CW\*(C`id == null\*(C'\fR. .PP Please note that you can only select from one table, joins are not supported and are not planned to be supported. If you need them, get a real \s-1RDBMS \s0(or send me a patch). .PP In the arithmetic expressions you can use a couple of \s-1SQL\s0 functions \*(-- currently supported are concat, substr (and substring), trim, ltrim and rtrim, length. I do not have an exact idea of which and how many functions I want to support. It's easy to write them in a couple of minutes now the interface is there (check the XBase::SQL module if you want to send a patch containing support for more), it's just that I do not really need them and sometimes it's hard to tell what is useful and what is \s-1SQL92\s0 compatible. Comment welcome. .PP The select command may contain and order by clause. Only one column is supported for sorting at the moment, patches are welcome. .PP The group by clause is not supported (and I do not plan them), nor are the aggregate functions. .SS "delete" .IX Subsection "delete" .Vb 1 \& delete from table [ where condition ] .Ve .PP The \f(CW\*(C`where\*(C'\fR condition is the same as for \fBselect\fR. Examples: .PP .Vb 3 \& delete from jobs ## empties the table \& delete from jobs where companyid = "ISW" \& delete from jobs where id < ? .Ve .SS "insert" .IX Subsection "insert" .Vb 1 \& insert into table [ ( fields ) ] values ( list of values ) .Ve .PP Here fields is a (optional) comma separated list of fields to set, list of values is a list of constants to assign. If the fields are not specified, sets the fields in the natural order of the table. You can use bind parameters in the list of values. Examples: .PP .Vb 4 \& insert into accounts (login, uid) values ("guest", 65534) \& insert into accounts (login, uid) values (?, ?) \& insert into passwd values ("user","*",4523,100,"Nice user", \& "/home/user","/bin/bash") .Ve .SS "update" .IX Subsection "update" .Vb 2 \& update table set field = new value [ , set more fields ] \& [ where condition ] .Ve .PP Example: .PP .Vb 2 \& update passwd set uid = 65534 where login = "guest" \& update zvirata set name = "Jezek", age = 4 where id = 17 .Ve .PP Again, the value can also be specified as bind parameter. .PP .Vb 1 \& update zvirata set name = ?, age = ? where id = ? .Ve .SS "create table" .IX Subsection "create table" .Vb 1 \& create table table name ( columns specification ) .Ve .PP Columns specification is a comma separated list of column names and types. Example: .PP .Vb 1 \& create table rooms ( roomid int, cat char(10), balcony boolean ) .Ve .PP The allowed types are .PP .Vb 2 \& char num numeric int integer float boolean blob memo date time \& datetime .Ve .PP Some of them are synonyms. They are of course converted to appropriate XBase types. .SS "drop table" .IX Subsection "drop table" .Vb 1 \& drop table table name .Ve .PP Example: .PP .Vb 1 \& drop table passwd .Ve .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Besides standard \s-1DBI\s0 attribudes, DBD::XBase supports database handle attribute xbase_ignorememo: .PP .Vb 1 \& $dbh\->{\*(Aqxbase_ignorememo\*(Aq} = 1; .Ve .PP Setting it to 1 will cause subsequent tables to be opened while ignoring the memo files (dbt, fpt). So you can read dbf files for which you don't have (you have lost them, for example) the memo files. The memo fields will come out as nulls. .SH "VERSION" .IX Header "VERSION" 1.08 .SH "AVAILABLE FROM" .IX Header "AVAILABLE FROM" http://www.adelton.com/perl/DBD\-XBase/ .SH "AUTHOR" .IX Header "AUTHOR" (c) 1997\-\-2017 Jan Pazdziora. .PP Contact the author at jpx dash perl at adelton dot com. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIperl\fR\|(1); \s-1\fIDBI\s0\fR\|(3), \fIXBase\fR\|(3); \fIdbish\fR\|(1) .PP Translation into Japanese (older version) at http://member.nifty.ne.jp/hippo2000/perltips/DBD/XBase.htm by Kawai Takanori.