Contents IndexPREPARE TO COMMIT statement READ statement

User's Guide
   Part VI. SQL Anywhere Reference
     Chapter 43. Watcom-SQL Statements
      PUT statement

Function

To insert a row into the table(s) specified by the cursor. See "SET statement" for putting LONG VARCHAR or LONG BINARY values into the database.

Syntax

     PUT cursor-name
          ...    [ USING DESCRIPTOR sqlda-name
              | FROM host-variable-list]
          
          ...    [ INTO DESCRIPTOR into-sqlda-name
              | INTO into-host-variable-list ]
          
          ...     [ ARRAY :nnn ]

Parameters

     cursor-name:    identifier, or host-variable

     sqlda-name:    identifier

     host-variable-list:    may contain indicator variables

Usage

Embedded SQL.

Permissions

Must have INSERT permission.

Side effects

None.

See also

Description

Inserts a row into the named cursor. Values for the columns are taken from the SQLDA or the host variable list in a one-to-one correspondence with the columns in the INSERT statement (for an INSERT cursor) or the columns in the select list (for a SELECT cursor).

If the sqldata pointer in the SQLDA is the null pointer, then no value is specified for that column. If the column has a DEFAULT VALUE associated with it, that will be used, otherwise a NULL value will be used. If no values are specified for any of the columns of one particular table involved in the cursor, then no row will be inserted into that table.

The second SQLDA or host variable list contains the results of the PUT statement.

The optional ARRAY clause can be used to carry out wide puts, which insert more than one row at a time and which may improve performance. The value nnn is the number of rows to be inserted. The SQLDA must contain nnn * (columns per row) variables. The first row is placed in SQLDA variables 0 to (columns per row)-1, and so on.

One table only
Values can be specified for columns of one table only. Inserting into two different tables through a cursor is not supported.

Inserting into a cursor
When inserting into a cursor, the position of the inserted row is unpredictable. If the cursor involves a temporary table, the inserted record will not show up in the current cursor at all.

Example

     EXEC SQL PUT cur_employee FROM :emp_id, :emp_lname;

Contents IndexPREPARE TO COMMIT statement READ statement