Empress provides two sets of Database Manipulation procedures for direct access to database structures via the C/C++ programming language the mx and mr routines. These interfaces provide faster execution times than any of the Query Language interfaces, since the parser is not invoked for each call. They also provide much greater control over what is done with the retrieved data, allowing you to perform complex arithmetic functions, generate custom-defined report formats, develop high-level user interfaces, and so on. It should be noted, however, that using the Database Manipulation procedures represents a greater programming effort than using the Shell, Batch or Standard C Interfaces.
The mx routines are considerably simpler than the mr routines, but should be used only for prototyping and simple programs. The mr routines should always be used where the application is particularly complex, or where speed is of the utmost importance. The mx routines are documented in the rest of this manual. The mr routines are documented in the Empress Host Language Interface: C/C++ Kernel Level - mr Routines manual.
The examples in this manual are illustrated in C programming language syntax.
For the UNIX systems, the mx routines support any version of the C programming language and they are callable from the C++ programs.
For Windows NT systems, the mx routines support Microsoft VC++.
The program examples used to illustrate the mx routines will access a database called repairs. This database contains the tables personnel and loans. The personnel table stores information about employees: the employee's personnel number, name, phone number, and credit limit. The loans table stores information about loans made to these employees: the employee's name, the date the loan was made, and the amount involved. The commands used to create the two tables, and their contents, are shown below.
CREATE PERSONNEL (number INTEGER, name CHAR (25, 1),
phone CHAR (15, 1), credit_limit DOLLAR (6, 1));
CREATE LOANS (name CHAR (25, 1), date DATE (1),
amount DOLLAR (6, 1));
They contain the following records:
*** Table: personnel *** number name phone credit_limit 10 Kilroy 426-9681 $500.00 3 Jones 667-2951 $500.00 5 Mosca 544-2243 $750.00 17 Wladislaw 723-6073 $200.00 8 Peterson 978-6060 $250.00 4 Scarlatti 961-7363 $100.00 *** Table: loans *** name date amount Mosca 2 February 1992 $150.00 Jones 7 February 1992 $ 33.95 Kilroy 16 February 1992 $250.00 Wladislaw 27 February 1992 $ 55.00 Jones 3 April 1992 $ 25.00 Mosca 4 May 1992 $200.00 Wladislaw 12 May 1992 $ 25.00 Peterson 6 June 1992 $ 50.00 Wladislaw 25 June 1992 $ 75.00 Jones 12 August 1992 $300.00 Scarlatti 5 November 1992 $120.00
You are encouraged to create a database containing these two tables, and use them in working through the examples presented in this manual.
However, do not run or test database applications from within your database directory. Work from a separate directory, as this reduces the danger of destroying database files and for general good house keeping.
Throughout this manual we assume that you are very familiar with the C programming language, as well as database principles. If you are not, please obtain copies of the references listed below, and read them thoroughly. This manual is intended as a guide and reference for accessing Empress from a C program, and is not intended as a general guide to programming or creating Empress applications.
Database
| Date, C. J. | (1995). An Introduction to Database Systems Addison-Wesley, Reading, Mass., 6th. ed. |
| ISO/IEC | 9075-4: 1996(E) Database Language SQL - Part 4: Persistent Stored Modules (SQL/PSM). |
| Tsichritzis, | D. T., & Lochovsky, F. H. (1977). Database Management Systems. Academic Press. |
UNIX
| Kernighan, | B. W., & Ritchie, D. M. (1978). The C Programming Language. Prentice-Hall, Inc., Englewood Cliffs, New Jersey 07632. |
| Kernighan, | B. W. & Ritchie, D. M. (1978). "UNIX Programming Second Edition." The UNIX Programmer's Manual, Vol.2, B. W. Kernighan & M. D. McIlroy (editors), Bell Telephone Laboratories, Inc., Murray Hill, New Jersey. |
Windows NT
VC++ 5.0 On-Line Help from Microsoft Corporation.