SQL/MP to SQL/MX Database and Application Migration Guide

Converting SQL/MP Applications to SQL/MX
Applications
HP NonStop SQL/MP to NonStop SQL/MX Database and Application Migration Guide666211-001
4-53
Statistics Area
NonStop SQL/MX does not provide the SQL communication area or use the INCLUDE
SQLCA directive. Instead, NonStop SQL/MX follows the ANSI SQL:1999 standard by
automatically providing a diagnostics area that stores completion and exception
information.
At the beginning of the execution of a SQL statement, the diagnostics area is emptied.
When the statement executes, NonStop SQL/MX places completion and exception
information in this area. You can use the GET DIAGNOSTICS statement to access the
information in the diagnostics area.
Suppose your application has executed a 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 performance and statistical 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.
Compiling the Application
After modifying the source code to be compliant with NonStop SQL/MX, compile the
source files by using the host-language compiler for that type of application. To
become familiar with SQL/MX development environments and understand how
embedded SQL/MX applications are SQL-compiled in NonStop SQL/MX, see:
Development Environments for SQL/MX Applications on page 4-54
Converting Guardian Applications to OSS on page 4-54