You can use the GETVAL statement to read data piecewise from a LONG column.
The GETVAL statements must follow a FETCH statement. Each GETVAL statement that follows this FETCH statement reads the next part of the content from the LONG column of the database table from the current position.
You have started to read the data from the LONG column with a FETCH statement.
EXEC SQL [<session_spec>] GETVAL INTO (<parameter_list>)
· Apart from the key word GETVAL, the GETVAL statement must be the same as the preceding FETCH statement. For example, the order and number of the parameters in the parameter list must be the same as the parameter list <parameter_list> of the FETCH statement.
· You cannot execute any other SQL statements between the FETCH statement and the subsequent GETVAL statement, or between the GETVAL statements themselves.
· If the host variable that corresponds to the LONG column has the data type SQLLongDesc, then you can read the total length of the LONG column in the corresponding structure component cbColLenafter the GETVAL statement has been executed.
· You can determine how often you need to execute the GETVAL statement by querying the warning message sqlwarn1. If sqlwarn1 has the value W, then the LONG column has not yet been read completely.
After the FETCH statement has been executed, the remaining content of the LONG column is read by the following statement:
while (sqlca.sqlwarn[1] == 'W')
EXEC SQL GETVAL INTO :i1, :l1, :l2;
· If you do not want a GETVAL statement to read the data of a certain LONG column, then assign the predefined constant SQL_IGNORE to the appropriate indicator value in this statement.