Using Constant Values in INSERT
The VALUES clause lists the values for the inserted columns. One or more of these values can be constants (that is, numbers or character strings).
When all the inserted values are constants, the PUT statement
has a special effect. Instead of creating a row and putting it in
the buffer, the PUT statement merely increments a counter. When you
use a FLUSH or CLOSE statement to empty the buffer, one row and a
repetition count are sent to the database server, which inserts that
number of rows. In the following example,
99 empty customer records are inserted into the customer table.
Because all values are constants, no disk output occurs until the
cursor closes. (The constant zero for customer_num causes generation
of a SERIAL value.) The following example inserts 99 empty customer
records into the customer table:
int count; EXEC SQL declare fill_c cursor for insert into customer(customer_num) values(0); EXEC SQL open fill_c; for (count = 1; count <= 99; ++count) EXEC SQL put fill_c; EXEC SQL close fill_c;