PUT statement

Use the PUT statement to store a row in an insert buffer for later insertion into the database.

Syntax


1  PUT
1 cursor_id_var
1 cursor_id
1  FROM + , output_var
2.1  INDICATOR indicator_var
2.1 $indicator_var
2.1 :indicator_var
1  USING
2.1  SQL DESCRIPTOR
2.2.1 'descriptor '
2.2.1 descriptor_var
2.1  DESCRIPTOR sqlda_pointer

Element Description Restrictions Syntax
cursor_id Name of a cursor Must be open Identifier
cursor_id_var Host variable = cursor_id Must be a character type; cursor must be open Language specific
descriptor Name of a system-descriptor area Must already be allocated Quoted String
descriptor_var Host-variable that contains descriptor Must already be allocated Quoted String
indicator_var Host variable to receive a return code if corresponding output_var receives a NULL value Cannot be a DATETIME or INTERVAL data type Language specific
output_var Host variable whose contents replace a question-mark ( ? ) placeholder in a prepared INSERT statement Must be a character data type Language specific
sqlda_pointer Pointer to an sqlda structure First character cannot be the ( $ ) or ( : ) symbol DESCRIBE statement

Usage

This statement is an extension to the ANSI/ISO standard for SQL. You can use this statement with ESQL/C.

PUT stores a row in an insert buffer that is created when the cursor is opened.

If the buffer has no room for the new row when the statement executes, the buffered rows are written to the database in a block, and the buffer is emptied. As a result, some PUT statement executions cause rows to be written to the database, and some do not. You can use the FLUSH statement to write buffered rows to the database without adding a new row. The CLOSE statement writes any remaining rows before it closes an Insert cursor.

If the current database uses explicit transactions, you must execute a PUT statement within a transaction.

The following example uses a PUT statement in :
EXEC SQL prepare ins_mcode from 
   'insert into manufact values(?,?)';
EXEC SQL declare mcode cursor for ins_mcode;
EXEC SQL open mcode;
EXEC SQL put mcode from :the_code, :the_name; 

The PUT statement is not an X/Open SQL statement. Therefore, you get a warning message if you compile a PUT statement in X/Open mode.