SQL/MX Comparison Guide for SQL/MP Users
Embedded SQL
HP NonStop SQL/MX Comparison Guide for SQL/MP Users—523735-003
4-10
Statistics Area
Suppose your application has executed an SQL statement and the WHENEVER 
statement reports an error. To find out more about the results of the executed 
statements, code your application to execute a procedure that uses GET 
DIAGNOSTICS:
For example, in a C program, the code might look like this:
/* First, get the count of the number of exception conditions. 
*/
EXEC SQL GET DIAGNOSTICS :hv_num = NUMBER, 
 :hv_cmdfcn = COMMAND_FUNCTION, 
 :hv_dynfcn = DYNAMIC_FUNCTION,
 ...; 
/* Second, get the i-th condition and process it. */
for (i = 1; i <= hv_num; i++) { 
 EXEC SQL GET DIAGNOSTICS EXCEPTION :i 
 :hv_tabname = TABLE_NAME, 
 :hv_colname = COLUMN_NAME, 
 :hv_sqlstate = RETURNED_SQLSTATE
 ...;
 ... /* Process the SQL error information. */
}
Statistics Area
NonStop SQL/MP provides a performance and statistics area (SQLSA) that enables an 
application to access this type of information about DELETE, INSERT, SELECT, 
UPDATE, OPEN, FETCH, DESCRIBE, and PREPARE statements. NonStop SQL/MX 
currently has no structure that corresponds to SQLSA and cannot provide information 
on what type of statement was compiled or on the cost of a PREPARE statement. 
Program Development
SQL/MP Compiler
Compiling programs using the SQL/MP compiler differs from using the SQL/MX 
compiler. In NonStop SQL/MP, compiling a host language program consists of these 
steps:
1. Create the host language source file with embedded SQL statements and 
directives.
2. Run the C or COBOL compiler to compile the statements in the source file.
3. Run the Binder program if necessary to bind object files.
4. Run the SQL compiler (SQLCOMP).
The result is a valid SQL program file, registered in the catalog and ready for 
execution. Graphically, this procedure appears similar to Figure 4-1.










