cfinsert

Inserts records in data sources from data in a CFML form
or form Scope.

It can be used instead of cfquery with insert sql command.

  <cfinsert datasource="" tablename="">

 cfinsert(datasource="", tablename="");

Attribute Reference

datasource string
Required

Data source; contains table.

tablename string
Required

Table in which to insert form fields.

ORACLE drivers: must be uppercase.
Sybase driver: case-sensitive. Must be the same case used
when table was created

tableowner string

For data sources that support table ownership (such as SQL
Server, Oracle, and Sybase SQL Anywhere), use this field to
specify the owner of the table.

tablequalifier string

For data sources that support table qualifiers, use this
field to specify qualifier for table. The purpose of table
qualifiers varies among drivers. For SQL Server and
Oracle, qualifier refers to name of database that contains
table. For Intersolv dBASE driver, qualifier refers to
directory where DBF files are located.

username string

Overrides username specified in ODBC setup.

password string

Overrides password specified in ODBC setup.

formfields string

Comma-delimited list of form fields to insert. If not
specified, all fields in the form are included.

If a form field is not matched by a column name in the
database, CFML throws an error.

The database table key field must be present in the form.
It may be hidden.

providerdsn string

dbtype string

dbname string

dbserver string

provider string

Compatibility

ColdFusion:

CF6+ providerdsn, dbtype, dbname, dbserver and provider are deprecated in all engines

Lucee:

providerdsn, dbtype, dbname, dbserver and provider are deprecated in all engines

Railo:

providerdsn, dbtype, dbname, dbserver and provider are deprecated in all engines

OpenBD:

providerdsn, dbtype, dbname, dbserver and provider are deprecated in all engines

Examples
Sample code using the cfinsert tag

Uses the cfinsert function to insert a record into the a users table based on a list form fields

cfinsert( datasource="myDsn", tablename="users", formFields="firstName,lastName,emailAddress" );

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub