Basic operations RETRIEVE was a non-relational database, that concept not being introduced until 1970. RETRIEVE databases contained a single table stored in a single file, which typically used a short-form of the database name as the filename. The table structure is defined when the database is created, allowing fields of character, integer or free-form numeric inputs. A database could have a maximum of 98 fields, with a maximum of 72 characters per field, and the total for any one row was 768 characters, or 256 words. Field names had to begin with a letter and could include additional letters, digits, a period and the @ character, with a maximum of 31 characters in total. The system was interactive, using a
command prompt within the system for user interaction. For instance, to start a new database the user would type at the command prompt, which would then respond by asking the user to type in the name for the database and then prompt for the field definitions. An empty line stops this process and sends it into data-entry mode, allowing rows to be entered. Any step of this operation could be removed by providing the data in the original command, for instance, if one typed instead of , the system no longer asked for the file name. There were three database file formats, which could be specified during , the normal character-format , which saved numbers in their 24-bit-based internal formats, and which encrypted the file with a user-supplied password. Existing databases were loaded using or (they were equivalent). Data was saved as it was changed, but there was also a command to write out data (or selections of it) to flat files. exited the system and returned to the underlying operating system.
Retrieving data Once the database was defined and populated, or an existing one was loaded, data could be displayed using . Without any parameters, it printed out all the records in the order they were entered, their "RECNO", which was printed at the front of the line. One could also provide a field list to select and reorder the fields in the printout, like . The statement worked almost identically, differing only in that it did not print out the RECNO at the start of the lines. was similar to , but suppressed the field headers as well. Individual records could be selected using the "record number addressing system", which was prepended to or . This was a flexible format allowing both single RECNOs separated by commas or ranges with colons to be specified, for instance, would print out the records 1, everything from 7 to 20, and then 50. It also included the pseudo-record to represent the last record, so printed out all records from 100 on. Records could also be selected by fields meeting certain criteria based on their contents, using the syntax. To list all the employees with a salary greater than $40,000, one would . The same syntax could be used to select single records based on their contents, not the RECNO, for instance . RETRIEVE supported all basic comparisons, , , , , and for not-equals, which was found in some contemporary
BASICs. Unusually, RETRIEVE also included English expansions of traditional comparisons, so one could use either or . Such expressions could also include basic math, including , , for multiplication, for division, and for exponentiation. These could be further combined with boolean expressions using , and . Additionally, the , and worked similar to or , including the same record selection concepts. As the name implies, these output a single value with their associated values. For instance, would likely return 1, while might return 42500. In addition to the //, a further output statement is . This works in a similar fashion, but has a number of options to
pretty-print the output. It can be invoked alone or with qualifiers as above, but when it is used it enters an interactive mode that asks a number of questions about where to send the output (with T being the terminal), whether it should be single or double spaced, include headers and totals, etc.
Modifying data Records could be deleted using the statement, using the same record selectors or field expressions as above. New records were inserted using . entered an interactive mode allowing the user to type in additional records field-by-field rather than entering comma-separated values a row at a time. read data from a comma-delimited text file into the current database already in memory. was used to update existing records; it worked similar to , loading into the current database from another file, but in this case included an additional qualifier . For instance, would read data from the file ADDRESSES and look in that file for a column where the first entry was "NAME". It would then process the file row-by-row, looking for entries in the database with that NAME and then updating the rest of the fields with the data from that row in ADDRESS. RETRIEVE supported two interactive methods to update existing records, and . worked similarly to the modern
SQL equivalent, , taking a selector expression of some sort, one or more fields, and the new values. For instance, one might . While ultimately did the same thing, it did so using an interactive mode. One invoked without the new value, for instance, . The system printed out that row and then allowed the user to edit the record. If there is more than one unique value, for instance, , each value was printed on a separate line and changes were sent to all matching records. was essentially identical to but did not print out the existing values first. Sorting was not performed at retrieval time, but was implemented by modifying the database and re-writing its contents in sorted order. This was accomplished with , followed by up to twenty field names. The original unsorted data is written to a backup file. The modifier could be used with any of the data modification statements to redirect the results to a new database. For instance, would append the data in the file FEBSALES to the current database and then save the results to CURSALES without updating the already-opened database. Or one might .
Other commands Utility commands included which printed out the
database schema, and which returned the number of records. ==Programming RETRIEVE==