* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download dbq - gaby.de
Open Database Connectivity wikipedia , lookup
Oracle Database wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Functional Database Model wikipedia , lookup
Ingres (database) wikipedia , lookup
Concurrency control wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Relational model wikipedia , lookup
Versant Object Database wikipedia , lookup
Clusterpoint wikipedia , lookup
>------!------!------!------!------!------!------!------!---------------------R >FP ON >TM 3 >BM 3 >HM 3 >FM 1 >PL 66 >SM 10 >CP ON >RJ ON >HE Stross/DOCUMENT_TITLE/% >LS 1© >FO______________________________________________________________________ ______ ð List of contents CONTENTS â DBQ database query language INTRODUCTION Introduction Overview of facilities COMMANDS Commands Interaction Procedures Command files Comments Editing File names Selection expressions Relational operators Aliases Notation COMMAND REFERENCE create insert update print find import export extract compress sort erase rename define show enter set help exit command file inclusion (@) DATABASE MAINTENANCE Introduction Setting up Security Reformatting USING THE DATABASE General points Query style Making a log file Joining multiple databases Limits REPORT FORMATTING Report formatting Field specifiers Heading specification Pause specification Uses of format files MESSAGES AND ERRORS Introduction Informational messages Error messages Other error situations >PA Introduction â DBQ is a powerful structured query language modelled on query language facilities available on large minicomputers. It is designed for use by those wanting an English like command language to enter database manipulation commands, rather than a menu driven interface. Because of this it cannot be used immediately by a complete novice in the same manner as menu driven systems, but it is easy to learn the basic commands in a few hours, and once learnt, it is considerably faster and more flexible to use. The commands operate against disk resident files. Because of this, there is no need to load or save database files explicitly, and the system is more resilient to power failures. However, due to the disk accessing, the processing is generally slower than memory resident databases. The query language provides a comprehensive set of functions for the creation, maintenance and enquiry of the database format supported by the DBQ system. The query language is the prime means of interaction with the database and it is important to become properly conversant with the many powerful commands before undertaking any major work using it. Because there is a finite limit on memory, many features found in more expensive databases have been left out of DBQ. Whilst important, these are by no means essential for personal databases. Such features include full arithmetic capabilities for updating fields and reporting, full report formatting with control totals, validation of input data at entry and high speed keyed access to data. Because of these, and other limitations, the database should be considered unsuitable for large scale commercial usage. â Overview of facilities â Database level commands permit the creation of a database, erasing a database, renaming a database, sorting a database on one or more fields, importing and exporting database records from and to external applications, and compressing a database to remove any deleted records from it. Record level commands include the insertion of records interactively or from a data file, the updating of selected records, the deletion of selected records, the selection of records into a working database, and the listing of selected records in tabular form or in a form specified by a format file. Specific fields can be selected in the update, find and print operations, and it is possible to do a relational join operation, whereby selected fields from two or more databases can be selected from records matched on some field or fields in the databases. Sequences of commands and data can be input from a file, and short sequences of commands can be defined as procedures, which can be executed simply by use of a keyword. In fact, simple groups of words can be defined in this way allowing aliases for keywords and keyword combinations. The command files and procedures can input variable data to be used in the evaluation of the command file or procedure. Command files and procedures can be nested to a certain level. Various options can be set, allowing control of the case sensitivity, causing a command file to be listed as it is executed, and switching a log file in or out to permit keyboard input to be logged for a number of purposes. Also tabulations can be split into pages, and the page length can be varied to accommodate different lengths of paper or different print formatting. Full online help is provided, permitting selection by initial letter of help topics. The command line input uses the CPM+ line input facilities, permitting full editing to be carried out on the current line, including the copying of the previous command using ^W. You are referred to the CPM+ documentation or the CPM+ help file for more information on this. The database is initially built to hold 10 records, but grows as new records are added. Records are updated in situ, and are deleted by flagging them as deleted. Deleted records can be compressed out of the database, and for occasions where a deletion selection was a bit too greedy it is possible to dump the deleted records out to a file for subsequent editing and re-input. â COMMANDSâ This section details each command in turn, providing the format of the command and details of the commands action. An example is also provided. Interaction Commands may be entered in free form. This means that line termination has no special meaning, and any number of spaces or tabs can be inserted at the start or end of a line or between elements. A command may be broken over more than one line, whereupon continuation prompts are issued to show that further input is expected. Where the end of a command has to be indicated, for example at the end of a print selection, either a new command or the command terminator ";" may be used. More than one command can be issued on the same line, although it is usually prudent to let each command execute before issuing the next in case of failure, and because an error will cause unused input for a command to be rejected as a syntax error. Procedures Procedures provide a means of entering a predefined block of text as input, identified by a name. They are included in the input by simply using their name, and can be used at any point of input where a keyword or identifier is expected. They can represent anything from a single word up to a set of commands, and can contain statements within them to prompt for variable data to be used when expanding them. Command files Command files are like procedures, but instead of fetching text from memory, the text is input from a file. The text can represent anything a procedure can represent, and can also contain prompting statements, for use as variable input, or as pauses in the command file execution. Comments Comments can be put on any line after a number sign "#", this usually being used for command files, or when logging the input. The comment acts as a command terminator, so cannot be inserted halfway through a command. Editing Line input is done via the CP/M line input routine, permitting editing to be done on the current input line, and the previous line to be recalled. This is useful when entering a long query line, as errors can be easily corrected. Data input for the INSERT and UPDATE functions is also done via this routine. File names File names with extensions indicated can be entered simply as the name without the extension, or if another extension is used, they may be entered within quotes, whereupon this is used as the full name. Database names cannot under most circumstances be entered as a string, and should always be entered as an identifier. A drive prefix can be put on any filename in either form, but a user area specifier is not permitted when entered in identifier form. Selection expressions A selection expression is a relational expression involving one or more database fields. A relational expression is simply a comparison between a field and a value (or another field). The types of comparison are called relational operators, and are listed below. A compound relational expression involving brackets and the logical operators 'and' and 'or' can be used to specify a complex selection. There follows some examples of selection expressions:balance > 10000 name } "Smith" sex = "male" and (age > 65 or age < 20) Note that in the last example, the brackets are necessary to join the two age comparisons together for use in the 'and' operation, otherwise the 'age < 20' would be separate and would satisfy the expression by itself. Relational operators The relational operators are as follows. = Equals > Greater than < Less than >= Greater than or equal to <= Less than or equal to <> Not equal to } Contains (substring search) For numeric fields, a numeric comparison is made. For character fields, a lexicographic comparison is made using the ASCII collating sequence. For the contains operator, a string search is done regardless of field type. The contains operator can be used as a "contained in" operator by simply reversing the operands (e.g. with "montuewed" } day). Aliases When specifying complex queries involving qualification of field names, and when joining a database with itself, a more convenient way of specifying fieldnames and database names is provided. The alias notation permits a temporary name, or 'alias' to be specified for field names or database names. This is done by specifying the alias directly after the normal name, without the comma separator used to specify elements in a list. The alias name can be used wherever the original name can be used, apart from in the field list or database list used to specify the aliases. Typically it would be used in a selection expression, or in a format file. The field alias is also used in the title line in a tabulation, and as the field name in a current working database created by a FIND command. For example, to join a family database between name and parent name, the following selection could be entered. DBQ> print family.name, parents.age dads_age DBQ> of family, family parents DBQ> with family.parent = parents.name ; This shows the database "family" being given an alias "parents" to show which instance of the database the age in the print list and the name in the comparison should come from. The parents age field also has an alias specified "dads_age" to allow the report produced to have a more applicable heading. Notation In this section, keywords are shown in uppercase, and other identifiers are shown in lowercase. This is done to permit the keywords to be easily identified, and does not imply that they must be used in uppercase. In fact the examples show normal command input in lowercase, and this is the recommended mode of use. Square brackets indicate optional elements of the command language. A second occurence of an element or set of elements within square brackets generally indicates that the set can be repeated a number of times. >PA CREATE database fieldname type size [scale] [fieldname type size [scale]] ERASE database RENAME database newname INSERT database DELETE selection ; UPDATE fieldnames OF selection ; PRINT [USING formatfile] fieldnames OF selection [INTO reportfile] ; FIND fieldnames OF selection ; SORT database BY fieldname [direction] [fieldname [direction]] ; IMPORT datafile INTO database EXPORT [DELETED] database [INTO datafile] ; EXTRACT database [INTO definitionfile] ; COMPRESS database DEFINE procedure / ENTER procedure SHOW {procedure} ; SET [NO] [FOLD] [VERIFY] [LOG] [PAGE [pagelength]] ; HELP EXIT Where identifiers are:database, newname : fieldnames : qualfieldname fieldname : type : size : scale : direction : selection : expression : comparison : primary relation : procedure : pagelength : datafile : formatfile : reportfile : definitionfile identifier : database file name (Identifier) (Ext. .DBQ) qualfieldname[+] [, qualfieldname[+] ...] | all[+] : [database.]fieldname field name (identifier) NUM | CHAR 1 to 12 NUM, 1 to 128 CHAR 0 to 10 for NUM fields only ASC (default) | DESC database [, database ... ] WITH expression [NOT] comparison [AND | OR [NOT] comparison ...] primary relation primary : qualfieldname | string | number = | > | < | >= | <= | <> | } procedure name (Identifier) length of paper in lines less 6 for heading data file name (Identifier) (Ext. .DAT) format file name (Identifier) (Ext. .FMT) report file name (Identifier) (Ext. .REP) : definition file (Identifier) (Ext. .DEF) Alpha [ alpha | "_" ...] >PA CREATE Syntax CREATE database fieldname type size [scale] {fieldname ...}; Details - database is the database name fieldname is a field name type is the field type (CHAR | NUM) size is the field length scale is the scale (decimal places) to be used when printing totals. The default value is 0 indicating an integer field (no decimal places). This scale is not used for field storage, although it is indicated whenever a field is input or updated. Stored decimal places beyond the scale are ignored in totalling. The field name, type, length (and scale specified for each field in the record. Example if required) are create accounts name char 10 acc_num num 6 balance num 8 2 ; This creates a database called "accounts", with three name, acc_num and balance. fields - >PA INSERT Syntax INSERT database Details This command allows records to be inserted in the database. It prompts for the fields in the record one by one. Brackets show the width of the field. [string] and <numeric> fields are indicated by the type of bracket. A number after <numeric> brackets indicates the number of decimal places. The brackets are only displayed as a visual guide, and the length shown is not enforced on input, although any field input longer than the width shown will be truncated when stored. Pressing just ENTER on the first field terminates displays the number of records inserted. Example DBQ> insert accounts name acc_num balance -----name [john smith] <123 > <2.34 > 2 [ ] [ 1 records inserted ] >PA UPDATE Syntax UPDATE {fields | ALL } OF selection; input, and Details - fields is a field list - selection is a record selection expression This allows you to update the specified fields in the selected records. The original value is printed first, and a prompt is issued to allow a new value to be input. If no value is entered before pressing ENTER, the original value is retained. After all records selected have been updated, a count of records updated is displayed. Example update balance of accounts with name = "john smith"; balance = 2.34 balance < > 2 >PA PRINT SYNTAX PRINT [USING filename] [{ fieldname[+], fieldname[+] . . . | ALL[+] } OF] selection [INTO repname] ; Details - USING filename indicates a format file (ext=.FMT) to be used for output formatting. field[+] is an optionally qualified field name with optional totalling (+) specified for numeric fields. ALL indicates all fields with optional totalling (+) of all numeric fields. selection is a record selection expression. repname is the name of an output file (ext=.REP) to be used instead of the terminal for output. (LST will cause output to the printer). For format file details, see the appropriate section. If the format file is not used, output is tabulated under headings in a fairly simple and straightforward manner. If totalling is specified, totals are printed for the selected records at the end of the tabulation. Headings consist of the field names forced to uppercase, with underscores changed to spaces. Aliases can be used to give the fields alternative headings. Totalling is usually only specified for numeric fields, but character fields with leading numerics can also be totalled if required. Example print name, acc_num account, balance+ of accounts with name } "smith"; NAME ACCOUNT BALANCE ============================== a smith 23 12.34 j smith 124 100.30 kb smith 21 4.20 ============================== 116.84 [ 3 records found ] >PA FIND SYNTAX FIND { field, field . . . | ALL } OF selection ; Details - field is an optionally qualified field name - ALL indicates all fields and can be abbreviated to * - selection is a record selection expression Creates a records. database called "CURRENT" containing the selected This command is used to create a working collection of records which can have sorts, selective deletions or prints made against it. It can also be used to cut down the processing necessary when joining a number of databases. It can also be used to reformat a database, although other means are available to achieve this if fields are to be added (see the section on reformatting). The names of fields can be changed by the use of aliases. Example find name, acc_num account of accounts with name } "smith"; rename current smiths print smiths; This selects the name field and the acc_num field (renamed to account) of those records containing the string "smith" in the name. It then renames the current database as the database "smiths", and prints it. >PA IMPORT SYNTAX IMPORT filename INTO database Details - filename is the name of a data file (ext .DAT) containing the values of the fields, one per line. - database is the name of the database to append the records to. Example DBQ> import accdata into accounts NOTE Data to be transferred from a BASIC program should simply be output one field per line using successive PRINT statements. e.g. Subroutine for outputting data, assuming opened for output, and closed afterwards. 2000 2010 2020 2030 REM OUTPUT DATA FOR DATABASE FOR IND% = 1 TO RECCOUNT% PRINT #9,ACCNAME$(IND%) PRINT #9,ACCNUM%(IND%) stream 9 is 2040 PRINT #9,ACCBAL(IND%) 2050 NEXT IND% 2060 RETURN >PA EXPORT SYNTAX EXPORT [DELETED] database [INTO filename] Details - database is the name of the database to export records from - filename is the name of a file (ext .DAT) to receive the records. If omitted, the records are written to the terminal. - the "DELETED" option exports those records that have been marked as deleted since the file was created or compressed. It is used to recover overambitious deletions. - records are written to the output file one field per line. Example DBQ> export deleted accounts into deldata >PA EXTRACT SYNTAX EXTRACT database [INTO filename] Details - database is the name of a database - filename is a file (ext .DEF) to receive the definition. If omitted, the definition is written to the terminal - this is handy for reminding you what fields are defined. - The definition is specified as the commands necessary to create the database again at the current size. Example DBQ> extract accounts create accounts name char 10 acc_num num 6 balance num 8 2 ; >PA COMPRESS SYNTAX COMPRESS database Details - database is a database name. This compresses active records at the start of the database file, and frees up space at the end for further records to be added. Example DBQ> compress accounts [20 records freed] NOTE To reduce the size of the file as well, assuming there is sufficient disk space, the following sequence may be used instead DBQ> DBQ> file DBQ> DBQ> find all of <database>; print; # To check if everything is O.K. before erasing erase <database> rename current <database> >PA SORT SYNTAX SORT database BY keyname1 {, keyname2} . . . ; Details old - database is a database name - keyname is the name of a field to sort on, optionally followed by "ASC" (default) or "DESC". - The sort order is major through minor (e.g. keynameN within keynameN-1 . . . within keyname2 within keyname1). - Records are sorted in situ. It takes a while for a large database. - It is not advisable to abort a sort halfway through - be patient. Example sort accounts by name, balance desc; >PA Erase a database ERASE DBQ Command Reference Syntax ERASE database Details - database is the name of a database The named database file is erased from the disk. It cannot be recovered except by immediate use of a program such as UNERA. This command is equivalent to the CPM ERA command, which can be used as an alternative. Example DBQ> erase current >PA Rename database RENAME DBQ Command Reference Syntax RENAME olddatabase newdatabase Details - olddatabase is the existing name of a database - newdatabase is the desired new name for the database The use of this command results in the same action as use of the CPM REN command, which can be used as an alternative. Example DBQ> find all of employees with dept = 300; DBQ> rename current ourdept >PA Define procedure DEFINE DBQ Command Reference Syntax DEFINE procname Details - procname is the name of the procedure to be defined DBQ prompts empty line definitions effectively you for the definition on subsequent lines. An is used to terminate the definition. As procedure overwrite previous definitions, a null definition deletes a procedure. Procedures can be used for a wide range of purposes. In its most simple form it can be used to set up synonyms for the query language command keywords for a non-English language, or for personal preference. Also it can be used for the following :To replace sequences of words with a single keyword. To specify part of, or all, a complex query. To specify a sequence of commands. To specify a sequence of commands with variable parameters input via the ENTER command (see ENTER command for details). Procedures can be nested. That is, a procedure can refer to another procedure within its definition. Procedures referring to procedures referring back to the original will cause problems when used, and must be avoided. Example DBQ> define total DEFINE> print all+ of DEFINE> DBQ> total accounts; >PA Show procedure DBQ Command Reference SHOW Syntax SHOW procname SHOW ; Details - procname is the name of the procedure to be listed - if procname is replaced by a terminator or keyword, a list currently defined procedures is shown. Example DBQ> show list print all of DBQ> show ; of list DBQ> Prompt for value ENTER DBQ Command Reference Syntax ENTER procname ENTER "procname" Details - procname is an identifier Causes a prompt to be issued for the identifier, and after reading one line, sets the procedure to that value. A null entry deletes the procedure. This is used in command files, and in other procedures, to prompt for input as part of a sequence of commands. The procedure in this case is just a simple value, but it is called in the same manner as a full multiline procedure. Where the procname is specified inside quotation marks, it indicates that the definition should be contained within quotation marks. This is used when entering string literals for comparison purposes. Example DBQ> define findemp DEFINE> enter empno: DEFINE> enter "name:" DEFINE> print all of employees with empno = empno: DEFINE> and name = name: ; DEFINE> DBQ> findemp DBQ> Enter empno: >PA Set options SET Syntax DBQ Command Reference SET [NO] [FOLD] [VERIFY] [LOG] [PAGE]; Details This permits specified. options to be set, or unset if "NO" is first The options are:NO The word "NO" changes the sense of the setting to that unset. Thus "SET NO FOLD;" would unset the fold option. of FOLD Fold permits alphabetic case folding on comparisons. e.g. "FrEd" would match with "fReD" VERIFY Verify causes the contents of command files to be output during execution. This may be used to check that the command file is running correctly. Comments should be inserted in the command file to keep track of where you are. LOG Log causes a log file to be created, and all input from the terminal to be written to it. Unsetting log simply switches off the writing, and subsequent setting of the log simply switches on the writing again. When the "exit" command is issued, the file is closed and a message output saying that it has been closed, prior to DBQ finishing. PAGE Page allows pagination to be done on tabulations. Simply setting page will set a pagelength of 60 detail lines, correct for 11 inch depth paper. Other page depths can be accomodated by quoting the number of detail lines to be printed per page after the set page command. e.g. set page 20 sets the pagelength at 20 detail lines. If page in unset, an effective page length of 32000 is and no page number will be printed. set up, Pagination is effective on both normal print tabulations and on format file driven output, for which a special value may again be required depending on page layout. Set display After the options have been set or unset, the current settings are displayed. Each option name is followed by a number. For FOLD, VERIFY and LOG, a value of 0 indicates unset, and 1 indicates set. For PAGE, the page length is displayed. Example set fold page 62 no verify ; Fold = 1, verify = 0, log = 0, page = 62 >PA Online help HELP Syntax HELP ? DBQ Command Reference Details This causes an initial page of help information to be output to the terminal. A prompt is then issued to press ^Z, ENTER, or a character. If ENTER is pressed, the next page of help is printed. If ^Z is pressed, the program returns to the DBQ> prompt. If a character is pressed, the next help page relating to a topic starting with that character is displayed. If a character is pressed which is not the initial of any remaining help frame, DBQ returns to the DBQ> prompt. Example DBQ> help --- page of help --Press ^Z to abort, ENTER to continue, or x for help on x... c --- page of help on "create" -->PA Exit from DBQ DBQ Command Reference EXIT Syntax EXIT Details This returns you to the CPM+ prompt. If a log file is currently open (although not necessarily being written to), it is closed and a message to that effect is displayed. Example DBQ> exit A> >PA Command files DBQ Command Reference @ Syntax @filename Details - filename is the full name of a file containing commands. This causes the contents of the specified file to be inserted at the current point in the input. The command file may contain any input, apart from the response to an "enter" request. If "verify" is set, the contents of the file are output terminal as it is read. to the If the file "DBQINIT.CMD" is present when DBQ is started, it is executed initially, and can be used to set up procedure definitions etc. Comments can be inserted in a command file, or indeed in direct input, by preceding them with "#". Everything on a line after a "#" is ignored. The ENTER command can be used to input variable data for use within the command file, in a similar manner as within a procedure. Also, an ENTER command for a dummy variable can be used to halt the command file execution until you respond to the enter request. The dummy variable can be immediately used as a command on the next line, and will allow you to enter "exit" to exit from DBQ if there is a problem. >PA Database administration MAINTENANCE DBQ Usage notes Introduction To effectively control your databases, it is necessary to beyond just setting them up and using them. think This section describes some requirements of proper database administration and suggests ways of achieving these. Setting up A number of things can be done to make life easier when using DBQ. The DBQINIT.CMD file can be used to set up procedures to be used either generally or against a specific database. These procedures may be simple abbreviations for database print requests etc. or they can be larger sequences of commands to enable interactive working against the database using the "enter" command. It is also possible, on the Amstrad CPC, to set up common commands on the keypad. A sample keypad definition file is provided which can be used as the basis of a custom keypad definition. The CCP key configuration is useful also, as it sets the cursor keys to support the CCP editing functions used by DBQ. Security Security covers two aspects of data management. The first is the protection of confidential information. For personal computers this is not usually a problem, but if you do share a machine with others, it is suggested that you keep confidential databases on specific disks which you can put in a safe place. The other aspect of security is insurance against data loss. This can be achieved for most purposes by making regular backup copies of your database disks. If you are planning on doing a long session on a database, firstly copy the database to a backup disk, then set the log option when you start the DBQ session. If something goes wrong during the session, the log file will contain the commands you entered and can be used as a command file against a new copy of the database from the backup (do not use the backup itself!). It is possible to edit the command file to truncate the file at some known point. It is then possible to recover nearly up to the point at which things went wrong. Reformatting It is possible to reformat the database in a number of ways. When a FIND command is done, a CURRENT database is created which can be renamed as a permanent database. Thus fields can be renamed or dropped, or data from more than one database can be used to form a new one. If a new field is needed in a database, it can be added by creating a temporary database with just one record containing the new field or fields in it, with the initial value, and joining this with the main database in a select operation. >PA Database administration MAINTENANCE DBQ Usage notes It is also possible to reformat a database by exporting the records, creating a new database with the required format, editing the data file and importing the datafile into the new database. It may be useful to specify a format file to create an output file already in the new format to be imported - e.g. >field2< >field1< newfield value >field3< If this is used to PRINT the old database containing three fields, the data can then be imported into the new database containing four fields. >PA General notes GENERAL DBQ usage notes General points DBQ is designed to be simple to use, and reasonably foolproof. There is no need to explicitly open or close databases, or to do saves to the disk, as the database is opened and closed for each operation. This means that when you are at the DBQ prompt, there are no databases currently open, and it is safe to abort the program using ^C, or by taking out the disk and switching off the computer. Query style Whilst the query facility is very powerful, it is often not the best approach to request a large complex selection at one go. If you are using the query facility as a means of choosing from the available records, it is better to firstly see how many records a more general search will produce, and then add further refinements until a suitable subset is found. For example, if we have a database of cars containing information about all current production cars, and we wish to select one to suit a particular customer, we can reduce the selection on some important criteria firstly, such as the price, and then select from the resultant cars. For example:DBQ> find cars with price < 5000 and price > 2500; DBQ> print current with doors = 4 and mpg > 40; Making a log file There are two ways of making a logfile of the interaction with DBQ. The SET LOG option allows input to be logged, and the resultant file can be used as a command file, either directly or after being edited. It is also possible to use the CPM+ 'put' transient to redirect the console output to a file, for example by using the command 'put console to file conout.log'. This will permit a full log of both input and output to be obtained. Joining multiple databases One of the properties relational databases is the ability to join together the data from two or more databases, based on the relationship between them. DBQ uses the power of the selection expression to not only express the required relationship between the databases, but also to select from the resultant data that which meets selection criteria in the same manner as selection from a single database. The relationship can be expressed not only in terms of single field equivalence, but of multi-field relationships. For a simple multi-database join, a straightforward on the related fields is all that is required. comparison DBQ> print parts.partno; all of orders, For a more complex join, the further specification. parts required with order.partno relationship will = need DBQ> print all of employees, depts with employees.dept >= DBQ> depts.lowdept and employees.dept <= depts.highdept; This joins the employees file with the department records for which they are within the department number range. For selections involving more than two databases, the extra relations can be specified between any of the participating databases. It is also possible to join a database with itself, although this demands the use of a database name alias, and appropriate qualification. Further details of this are provided in the section on aliases. Limitations The various limits that DBQ has on data storage are as follows:Maximum size of any one database file - 64k bytes. Maximum numeric field length (including sign bytes. and Maximum number of decimal places - 10. Maximum character field length - 128 characters. Maximum number of fields in database - 30. Maximum field name length - 10 characters. Maximum database name length - 10 characters. Maximum procedure name length - 10 characters. point) - 12 Maximum command line length - 128 bytes. - Although a number of lines can make up a command. As well as these limits, there is a limit on the amount of dynamic memory that can be allocated for file buffers, etc. This is quite high, and handles a fairly complex query against three database files of 5 fields at the same time as using a command file for input, a format file for output formatting, output to a report file, with a current log file being produced, and with about 2k to 3k of procedure definitions. Details of how to deal with a memory full error are contained in the section on error messages. >PA Output formatting REPORTS DBQ usage notes Report formatting The PRINT command normally lists the records in tabular form. Other formats are possible using the format file. The USING option on the PRINT command can specify the name of a format file (Default extension .FMT). This format file contains the text to be output, together with an indication of where the fields are to be printed. In its simplest form, it contains the field specifiers only, but it can also contain heading text and a flag character to cause a pause at the terminal after each record. Field specifiers Field specifiers come in two forms, as follows. <fieldname> and >fieldname< The first of these indicates that the field should be printed as its full width. For character fields, the field is left justified with space fill to the right. For numeric fields, the field is right justified with space fill to the left. The second form indicates that the field should be printed in minimum width form, whereby only the necessary characters are printed, and no space fill occurs. This form is used for such purposes as mailmerge where the surrounding text can be properly concatenated with the field value. Note that the field name used can be the normal field name, or an alias if one has been specified. It is preferable to use aliases if qualification is otherwise necessary due to the field name not being unique to one database. Heading specification A percent sign "%" at the start of the file indicates that any following text up to the next percent sign is heading text and should only be output once at the start. Careful positioning of the percent signs permits the correct spacing of the heading lines. The number of heading lines should be used when calculating any page length setting. When pagination is in effect (see the SET PAGE option), the heading will be printed every time the specified number of records have been printed. Careful specification of the text areas is necessary to achieve correct results from this, and some experimentation is invariably necessary. A number sign ("#") within the heading text will be replaced by the current page number. The number sign will also be recognized within the detail text, and permits the page number to be output for each record if desired. Pause specification A question mark "?" at the end of the format file indicates that the output should stop at this point before printing the next record. The operator may then press ENTER to print the next record, or ^Z to stop the printing. This may be used for browsing through the file on the screen, or for printing mail merge output onto single sheets of paper. Uses of format files The format file facilities provide a range of formatting possibilities beyond the immediately obvious. The following list provides some suggestions, although these are by no means all the possibilities. Alternative tabulations, with differing heading styles with page numbering at specified points. Single, double, triple or indeed any line spacing. Unit specifiers for value fields (e.g. 25143 cwt, 96 cc, etc.). Fields duplicated on same or different lines. Paged browsing, using nicely formatted screens containing the fields in forms with fancy titles, side headings and borders. Printout of database onto forms, again with headings etc. Mail merge, using a letter produced on a word processor, with field specifiers at appropriate points. Formatting of data for input to a BASIC or other applications program. (e.g. ">string field<",>numeric field<,constant data,>another field<). Formatting of data to permit reformatting of the database file itself. An example of this is given in the section on reformatting. Label printing, using a simple format file. And of course the data used in these various formats of output can come from selected fields from a complex selection from more than one database. >PA Messages and Errors MESSAGES DBQ User manual Introduction The following list of messages describe the likely cause of each error situation, and where applicable corrective action that may be taken. Informational messages These messages are printed for your information, and do not indicate that anything has gone wrong. The following informational messages will appear. DBQ.LOG closed This is output when an EXIT command is issued, if the log file has been opened using the SET LOG command. It is used to remind you that the log file has been written, and that you should either do something with the log file, or delete it to free up the disk space occupied. Fold = ?, verify = ?, log = ?, page = ?? This is output whenever a SET command is issued, to show the resultant settings. Press ENTER to continue, ^Z to quit, x for help on x... This is output after each page of HELP information displayed, and gives you the option of viewing the next help page, quitting from the help display, or looking for the next help topic starting with the given letter. [ nnn records xxxxxx ] Where xxxxxx can = Freed. Found, Updated, Inserted, Deleted or This is output whenever a PRINT, FIND, UPDATE, INSERT, DELETE or COMPRESS command is issued, and indicates the number of records taking part in the operation. Press ENTER to continue, ^Z to quit This is output after each record is printed, prompting character is specified in a format file. if the nnnn swaps in nnnn passes This is output after a sort operation completes, to indicate how many record swaps took place. A large number will indicate that the file was not close to the sort order requested. >PA Error messages These messages indicate that the requested action could not be performed as requested. In certain cases a complete query may have been recognized up to the point of a syntax error. In this case, the query will have been actioned, but error will also be reported. These errors will be printed in the general form:### Error: error details ### Where "error details" are specific error types, and will be one of the following:syntax error This is the most common message and indicates that DBQ did not understand the command that you issued. Generally, this means that you have typed a command name or other keyword incorrectly, but can mean that the order of the words in the command is incorrect, or that certain options are not available on the command. It can also be caused by a string literal not being enclosed in quotation marks. If you are in doubt about what word the error was raised on, try typing the command in one word to a line. As soon as an error is detected, the message will be output. Whilst this helps in the majority of cases, in some cases the actual word or construct in error is earlier on in the query, and is only brought to light when the command is terminated. set parameter unknown An incorrect option has been specified for the SET Check the spelling of options in the SET command. command. memory full This message indicates that the dynamic memory of the system is full. If this message is reported, steps can be taken to release some memory, by deleting unwanted procedures, and by not using a log file. It is recommended that an exit is made, and DBQ restarted, without defining unwanted procedures, and without starting a log file. This will remove any fragmented dynamic memory, and provide the maximum space to run a query. If this still fails, the query will have to be reduced in size or complexity. It may help on a query against a number of databases to use the FIND command to select the required data into a temporary database as an intermediate step, and reduce the overhead caused by having a number of databases open. Quite often a little experimentation will cure the problem. disk full This indicates that the disk to which you are writing does not have enough space to write a file. You should exit from DBQ and tidy up the disk before proceeding. database file not found The database file that you specified does not exist. Either you have mispelled the name of the database, or you are using the wrong disk. database name undefined The database name specified in a selection expression has not been used in the database name list of the command. bad file header The database file specified does not have a valid DBQ header section. You may have renamed a non-DBQ file with the .DBQ extension, or the database file may have been corrupted in some manner. Restore the latest backup copy and bring the database up to date. If you don't have a backup copy, read the section on database administration, ready for the next disk corruption. creating database An error has occurred whilst creating the database. This may be due to the database name already being in use, or the disk being write protected. field name duplicated When creating a database, a fieldname than once. has been used more field name ambiguous Within a query, a field name has been used that appears in more than one of the databases named. In this case, the name should be qualified by prefixing it with the database name and a full stop. expression too complex A selection expression has been used that is too complex to parse. It is usually necessary to reduce the complexity. It may be sufficient to specify the expression in a different manner. too many fields Too many fields have been specified for a database, during a CREATE operation. reading record An error occurred when reading a record. the disk having been removed. writing record This may be due to An error occurred when writing a record. This may be caused by the disk being full, or by the disk being removed during the command. input file not found The input file specified cannot be found on the disk. creating output file An error occurred whilst attempting to create the specified output file. This may be due to the file already existing, or the disk being write protected. command file not found The specified command file could not be found on the disk. Also the following error messages may appear as shown:### Maximum line length is 128 ### Re-enter> An input line longer than the allowed maximum has been used. To overcome this problem simply split the command up and enter it on multiple lines. ### Out of memory using <procname> ### Dynamic memory was exhausted when attempting to expand the named procedure. See the 'memory full' error for an explanation of likely causes and suggested remedial action. ### Error opening ICF <filename> ### An error occurred when command file named. attempting to open the indirect ### Procedure <procname> not found ### A definition for the named procedure could not be found. Sorry - help file not available. The help file 'DBQ.HLP' is not present on the disk. You will probably have removed it due to its size. It is possible to produce a reduced file with just the summary details on it by editing the full file, after taking a backup copy. You can add any useful information or personal notes and hints at the end of the file. Other error situations Other occasions may arise where an erroneous situation can be assumed to exist. Certain obscure combinations of circumstance may, perhaps, result in the computer entering a "hard loop". This situation is easy to detect, as it is impossible to break out of the program by the usual means of pressing control-C, and the disk drives may remain running but not doing anything. If this is the case (and you have not pressed a combination of keys which switches the printer output on when a printer is not attached, which results in an error message being displayed by CPM+ on the bottom line of the screen after a delay of around 20 to 30 seconds), it will be necessary to carefully shut the computer down and reboot CPM. >PA >PA his case, the query will have been