The SQL commands currently supported by DBD::XBase's prepare are:
select
select fields_or_expressions from table [ where condition ]
[ order by field ]
Fields_or_expressions is a comma separated list of fields or arithmetic expressions, or a "*" for all
fields from the table. The "where" condition specifies which rows will be returned, you can have
arbitrary arithmetic and boolean expression here, compare fields and constants and use "and" and "or".
Match using "like" is also supported. Examples:
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 'Ki%' order by last_name
select id + 1, substr(name, 1, 10) from employ where age > 65
select id, name from employ where id = ?
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 DBI(3) for details. To check for NULL values
in the "where" expression, use "id is null" and "id is not null", not "id == null".
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 RDBMS (or send me a patch).
In the arithmetic expressions you can use a couple of SQL 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 SQL92 compatible.
Comment welcome.
The select command may contain and order by clause. Only one column is supported for sorting at the
moment, patches are welcome.
The group by clause is not supported (and I do not plan them), nor are the aggregate functions.
delete
delete from table [ where condition ]
The "where" condition is the same as for select. Examples:
delete from jobs ## empties the table
delete from jobs where companyid = "ISW"
delete from jobs where id < ?
insert
insert into table [ ( fields ) ] values ( list of values )
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:
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")
update
update table set field = new value [ , set more fields ]
[ where condition ]
Example:
update passwd set uid = 65534 where login = "guest"
update zvirata set name = "Jezek", age = 4 where id = 17
Again, the value can also be specified as bind parameter.
update zvirata set name = ?, age = ? where id = ?
createtable
create table table name ( columns specification )
Columns specification is a comma separated list of column names and types. Example:
create table rooms ( roomid int, cat char(10), balcony boolean )
The allowed types are
char num numeric int integer float boolean blob memo date time
datetime
Some of them are synonyms. They are of course converted to appropriate XBase types.
droptable
drop table table name
Example:
drop table passwd