Processing a cursor dynamically is nearly identical to processing it using static SQL. When a cursor is declared, it is associated with a query. By using the FETCH statement the cursor is positioned on the next row of the result table and assigns the values of that row to host variables.
In static SQL, the query is a SELECT statement in text form, while in dynamic SQL, the query is associated with a statement name assigned in a PREPARE statement. Any referenced host variables are represented by parameter markers.
The main difference between a static and a dynamic cursor is that a static cursor is prepared at precompile time, and a dynamic cursor is prepared at run time. Additionally, host variables referenced in the query are represented by parameter markers, which are replaced by runtime host variables when the cursor is opened.
Language | Example Source Code |
---|---|
C/C++ |
|
COBOL |
|
FORTRAN |
|
REXX |
|