SQL/MX 2.x Database and Application Migration Guide (G06.23+, H06.04+, J06.03+)

Converting SQL/MP Applications to SQL/MX
Applications
HP NonStop SQL/MX Database and Application Migration Guide540435-005
10-53
Statistics Area
For information about handling errors, see Diagnostics Area.
In NonStop SQL/MP, the WHENEVER declarative requires a colon (:) before the target
location for the GO TO, PERFORM (in COBOL), or CALL (in C) actions. This
restriction is removed in NonStop SQL/MX.
Diagnostics Area
NonStop SQL/MP provides a communication area (SQLCA) that enables an
application program to check the status of SQL statement execution. You can use the
INCLUDE SQLCA directive to declare the communication 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 an 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 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 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