You can use PUTVAL statements to insert data in a LONG column piecewise.
The PUTVAL statements must follow a INSERT statement. Each PUTVAL statement that follows this INSERT statement appends the current content of the corresponding host variable to the LONG column of the database table.
You have started to insert the data in the LONG column with an INSERT statement.
EXEC SQL
[<session_spec>] PUTVAL INTO <table_name>
[(<column_name>,...)] VALUES
(<parameter_list>)
· Apart from the key word PUTVAL, the PUTVAL statement must be the same as the preceding INSERT 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 INSERT statement.
· Before each PUTVAL statement, assign the new data to the host variable for the LONG column.
· The PUTVAL statement ignores any values in the parameter list that refer to table columns other than the LONG column.
· You cannot execute any other SQL statements between the INSERT statement and the subsequent PUTVAL statement, or between the PUTVAL statements themselves.
Every other SQL statement closes the LONG column in the database table, so that no more data can be appended.
· Inform yourself about the special features when using the data type SQLLongDesc.
· If you want to insert more than one row in a table, use an array statement.
EXEC SQL CREATE TABLE LONGTEST
(I1 INTEGER, L1 LONG BYTE, L2 LONG BYTE);
EXEC SQL BEGIN DECLARE SECTION;
int array_size;
VARCHAR l1[100][500], l2[100][50];
int i1[100];
EXEC SQL END DECLARE SECTION;
array_size = 100;
EXEC SQL FOR :array_size INSERT INTO LONGTEST VALUES
(:i1, :l1 :il1, :l2 :il2);
· If you do not want a PUTVAL statement to insert any data in a certain LONG column, then assign the predefined constant SQL_IGNORE to the appropriate indicator value in this statement.
You cannot insert LONG data with the length NULL.