SQL/MX Comparison Guide for SQL/MP Users

Embedded SQL
HP NonStop SQL/MX Comparison Guide for SQL/MP Users523735-003
4-4
Embedded SQL Statements
For example, suppose the columns PARTDESC and QTY_AVAILABLE in the PARTS
table allow null. After the SELECT statement executes, this C example tests the
indicator variable for null or a truncated value:
EXEC SQL SELECT partnum, partdesc, price, qty_available INTO
:parts_rec.partnum,
:parts_rec.partdesc
INDICATOR :parts_rec.partdesc_i,
:parts_rec.price,
:parts_rec.qty_available
INDICATOR :parts_rec.qty_available_i,
FROM sales.parts
WHERE partnum = 300380 AND partnum = 2402 ;
...
if (parts.qty_available_i < 0) handle_null_value();
if (parts.partdesc_i > 0 ) handle_truncated_value();
...
In NonStop SQL/MP, the indicator variable is not set to the source length in the case of
truncation. It is set to 0 if it is a nonnull value and if the value is null, the indicator
variable is set to -1.
Embedded SQL Statements
Most SQL/MP embedded SQL statements exist in NonStop SQL/MX. However, a few
of the statements, options, and clauses have been dropped because of SQL:1999
ANSI changes.
Table 4-1. Embedded SQL Statements
SQL/MP Embedded SQL
Statements and Directives
Implemented
in NonStop
SQL/MX? Comments
CLOSE Yes
DECLARE CURSOR Changed See Updatable Cursors
.
DESCRIBE Changed NonStop SQL/MX uses an SQL descriptor
area, as defined by ANSI SQL:1999. See
Descriptor Area
.
DESCRIBE INPUT Changed NonStop SQL/MX uses an SQL descriptor
area, as defined by ANSI SQL:1999. See
Descriptor Area
.
EXECUTE Changed No RETURNING clause in NonStop
SQL/MX.
EXECUTE IMMEDIATE Yes
FETCH Changed NonStop SQL/MX requires the number of
host variables in the fetch list to be the same
as the number of values returned in the
cursor specification.