SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Static Rowsets
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
7-9
Selecting Rows Into Rowset Arrays
At the beginning of the execution of an SQL statement, the diagnostics area is
emptied. When the statement executes, NonStop SQL/MX places information on
completion or exception conditions into this area. The diagnostics area consists of:
•
Statement information: Header area with information on the SQL statement as a
whole
•
Condition information: Detail area with information on each error, warning, or
completion code that occurs during the execution of the SQL statement
The number of retrieved rows is stored in the ROW_COUNT field of the statement
information in the diagnostics area. You can retrieve the value in the ROW_COUNT
field by using the GET DIAGNOSTICS statement. In the preceding example, the
statement that retrieves the value of ROW_COUNT is specified as:
EXEC SQL GET DIAGNOSTICS :numrows = ROW_COUNT;
For further information, see the GET DIAGNOSTICS statement in the SQL/MX
Reference Manual.
Selecting a Column With Date-Time or INTERVAL Data Type
If a column in the select list has an INTERVAL or standard date-time (DATE, TIME, or
TIMESTAMP, or the SQL/MP DATETIME equivalents) data type, use the INTERVAL or
date-time data types.
If a column in the select list has a nonstandard SQL/MP DATETIME data type that is
not equivalent to DATE, TIME, or TIMESTAMP, use the CAST function to convert the
column to a character string. You must also specify the length of the target host
variable (or the length–1 in the case of a C program) in the AS clause of the CAST
conversion.
For more information on declaring date-time or INTERVAL data types, see Section 3,
Host Variables in C/C++ Programs and Section 4, Host Variables in COBOL Programs.
Examples
This example uses a typical context for selecting a standard date-time value. The
number of rows in the PROJECT table with a start date less than or equal to 1998-12-
01 does not exceed 200:
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
ROWSET [200] unsigned NUMERIC (4) hva_projcode;
ROWSET [200] char hva_projdesc[19];
ROWSET [200] DATE hva_start_date;
...
long numrows;
EXEC SQL END DECLARE SECTION;
long i;
...
EXEC SQL
SELECT projcode, projdesc, start_date
C