SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Static SQL Cursors
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
6-14
Using Floating-Point Data Types
/* Initialize the value in the WHERE clause. */
printf("Enter minimum estimated number of days: ");
scanf("%s", in_est_complete);
/* Open the cursor using this value. */
EXEC SQL OPEN get_project;
/* Fetch the first row of the result table. */
EXEC SQL FETCH get_project
INTO :hv_projcode,:hv_projdesc,:hv_est_complete;
while (strcmp (SQLSTATE, SQLSTATE_NODATA) != 0) {
/* Process the row in some way. */
...
/* Fetch the next row of the result table. */
EXEC SQL FETCH get_project
INTO :hv_projcode,:hv_projdesc,:hv_est_complete;
}
/* Close the cursor. */
EXEC SQL CLOSE get_project;
Using Floating-Point Data Types
You can retrieve floating-point data from SQL/MP and SQL/MX tables to an application
program. The type of float returned to the application (IEEE or Tandem) depends on
the float host variable that was declared. Based on the declared type, NonStop
SQL/MX converts and returns floating-point values to the application in the appropriate
form.
If the application directs the SQL/MX preprocessor to declare host variables in IEEE
floating-point format and then compiles and links the program with Tandem floating-
point format, an application error occurs and incorrect floating point values are
returned. This problem also occurs if the host variable is declared as Tandem floating-
point and linked as an IEEE floating-point value.
Considerations When Using a Cursor
•
If the cursor locks or updates an audited table, the OPEN and FETCH operations
and any subsequent cursor operations must be within a transaction.
•
A process that uses a cursor must have read authority for tables and views
referred to in the SELECT that specifies the cursor. If the cursor declaration
specifies FOR UPDATE, the process must also have write authority for the
referenced table, view, and base tables underlying the view.
If you use a cursor to locate rows to delete or update without specifying FOR
UPDATE in the declaration, NonStop SQL/MX checks only the read authority when
the OPEN executes, even though the delete or update requires write authority.
NonStop SQL/MX checks for write authority when DELETE or UPDATE executes.