NonStop Systems Introduction
The Relational Database Management System
NonStop Systems Introduction—527825-001
4-7
Conversational Interface
can contribute to these goals. How will the CEO’s staff find the names of the
employees in each department in order to contact them?
Instead of creating and maintaining elaborate lists that show who is in each
department, the CEO’s staff can query the EMPLOYEE table as shown in Figure 4-3
on page 4-6 to get a report showing which people are in a given department. Then
they can notify the members of the department about the meeting with the CEO. A
single SELECT statement can accomplish all this useful work—a very powerful feature
of SQL/MX.
Programmers can use the same SQL data manipulation statements in their database
programs that end users use conversationally. These statements have the same
powerful effect in programs that they have in end-user operations. A single SQL
UPDATE or DELETE statement can replace many lines of code in a conventional
record-at-a-time program by accessing a set of rows that match selection criteria. The
execution of the SQL statement can be much faster than that of the replaced code,
because SQL/MX performs less input/output activity than record-at-a-time programs.
To understand the economy of SQL code, suppose that a programmer wants to write a
program that gives a five percent raise to all the employees in the EMPLOYEE table.
To accomplish this result, the programmer first declares a cursor (a pointer that
indicates the next row to be processed in a set of rows). Then the programmer uses
the cursor to make each row of the EMPLOYEE table available to the host program.
The program updates each row until there are no rows left to process.
The programmer needs to write only one SQL UPDATE statement to update all the
rows in the table, as in the following Java example:
#sql [ctx] {DECLARE salary_bonus CURSOR FOR
UPDATE employee
SET salary = salary * 1.05
WHERE CURRENT OF CURSOR salary_bonus};
Refer to the SQL/MX Query Guide for more information about database queries.
Conversational Interface
SQL/MX provides a conversational interface known as MXCI (MX Conversational
Interface). This interface serves two purposes:
•
For ad hoc queries or updates of a few rows, the occasional user (usually a
database administrator or business analyst) can use simple SQL statements to
quickly access the desired table or view. An extensive online help facility guides
the user, and a report writer provides flexible formatting for professional quality
reports.
•
For development purposes, programmers can use the conversational interface to
interactively create and test a prototype of the data access portion of their
applications. They can also use the report writer to develop complex reports.