# INSERT Insert New Record in File

> Source: https://manual.pvxplus.com/directives/insert

## Format

**INSERT** (*chan*\[,*fileopt*\])*varlist*

***Where:***

|  |  |
| --- | --- |
| *chan* | Channel or logical file number of the file to which to write. |
| *fileopt* | Supported file options (see **[File Options](https://manual.pvxplus.com/appendix/input-output-and-control-options#Mark1)**):<br>\|  \|  \|<br>\| --- \| --- \|<br>\| **BSY**=*stmtref* \| Traps Error #0: Record/file busy \|<br>\| **DOM**=*stmtref* \| Missing record transfer \|<br>\| **END**=*stmtref* \| End-of-File transfer (File full) \|<br>\| **ERR**=*stmtref* \| Error transfer \|<br>\| **IND**=*num* \| Record index \|<br>\| **KEY**=*string$/num* \| Record key \|<br>\| **REC**=*name$* \| Record prefix where the ***name*** of the variable (rather than its contents) defines the prefix. (REC=VIS(*name$***)** can also be used where the ***contents*** of the *name$* variable defines the prefix.)<br>For more information on using the **REC=** option, see **[Prefixing Variables in an IOList via REC=](https://manual.pvxplus.com/pxplus-user-guide/file-handling/processing-data-files/input-and-output-parameters#Mark1)**. \|<br>\| **RTY**=*num* \| Number of retries (one-second intervals). This overrides the value defined by the **['WT'](https://manual.pvxplus.com/parameters/wt)** system parameter. \|<br>\| **SIZ**=*num* \| Number characters to read \|<br>\| **TBL**=*stmtref* \| Data translation table \|<br>\| **TIM**=*num* \| Maximum time-out value in integer seconds \|<br>\| *stmtref* \| Program line number or statement label to which to transfer control \| |
| *varlist* | Comma-separated list of variables, literals, or **IOL=** options. |

## Description

The **INSERT** directive is used to write a new record to a file (channel/logical file number). The syntax for this directive is identical to the [WRITE](https://manual.pvxplus.com/directives/write) directive; however, **INSERT** only writes a record if it ***does not exist*** and will return an error if the record already exists.

**INSERT** may be used against keyed, memory, ODBC and OCI files. When **IND=** is used with **\*MEMORY\***, this directive inserts a new index.

## See Also

[WRITE RECORD Write Record](https://manual.pvxplus.com/directives/write-record)  
[WRITE Add/Update Data in File](https://manual.pvxplus.com/directives/write)  
[UPDATE Update Existing Record in File](https://manual.pvxplus.com/directives/update)
