Use this macro to specify the database files, the names of the dBase3+ files (or delimited text files) from which the
records and fields are being taken. There can be one or more string
arguments which are the full names (or pathnames) of the file to use (the
.dbf
file extension is also required in the name). If the extension is
not .dbf
then the file will be read in as a delimited ascii file using
awk field/record style input by default, see
section Text Processing. The one exception to this is
where the extension is .sql
where the database file name is then just a
table to query in a RDBMS, see section RDBMS Queries. The example
program fragment below shows all three file types in use.
%%DATABASE "/usr/local/lib/dbase/example.dbf" %%DATABASE "ref1.txt" "ref2.txt" %%DATABASE "people.sql"
The first database file has a path of /usr/local/lib/dbase/
, a name of
example
and a type of .dbf
and will be opened as a dBase3+ file.
The next two database files have no path (so must be in the current directory),
names of ref1
and ref2
respectively and are both opened as delimited ascii
files. The third database file has no path (does not need one) and is
treated as an SQL query selecting the entire contents of the people
table
(people
will also be the name of the database file) from a RDBMS.
The first database file defined is always taken as the master database file (that which text body processing, sorting and filtering acts on and through which records are cycled). Other database files can only be accessed indirectly through the pointer mechanism of equate processing ( see section Field Reference).
The special case filename which is just "-"
can be used to read a database file
from standard input (this would normally always be specified as the first
database file so that it is also the master). A database file specified as
"-"
will always be loaded as a delimited ascii file.
Note that there must be at least one DATABASE command in every GRG file, in fact the smallest GRG file would just consist of one of these lines to define the database file -- the default header and record text bodies would then define the format of the output file automatically.
Note that the GPPDBFFILE and TEXDBFFILE predefined macros which the above replaces are deprecated and should nto be used.
Go to the first, previous, next, last section, table of contents.