webCOMAND

cQL INSERT Statement

The INSERT statement creates new objects in the repository and is similar to an SQL INSERT statement.

An INSERT statement is made up of the following clauses.  If multiple clauses are specified, they may appear in any order, but it is recommended they appear in the following order.

  • INSERT - Specifies which fields and calculated values to return for each resulting object or row.
  • SET - Restricts results to objects of one or more content type(s).
  • VALUES - Restricts results to objects of one or more content type(s).
  • IN - Optional cPath that specifies the folder to insert the new objects into.  If not provided, the objects will not be added to a folder, unless the individual object's Folders fields are set.

INSERT

The INSERT clause is similar to the SQL equivalent, except a Content Type name is specified instead of a table name.  For example:

INSERT Contact SET Name='Jenny', Phone.Number='867-5309'

Similar to the SQL, the INTO keyword is option.

INSERT INTO Contact SET Name='Jenny', Phone.Number='867-5309'

SET

The SET clause is similar to the SQL equivalent, except dot-notation fields may be specified to set "deep" content.

INSERT INTO Contact SET Name='Jenny', Phone.Number='867-5309'

Reference fields can be set to the OID, DOID or UUID of the target object.  Multiple INSERT statements are required to set list field values.

VALUES

The INSERT clause can also specify a set of fields and set their values with the VALUES clause.  For example:

INSERT Contact (Name, Phone.Number) VALUES('Jenny', '867-5309')

Multiple comma-separated sets of values can be specified as well.

INSERT Contact (Name, Phone) VALUES('Jen', '867-5309'), ('Al', '867-5308')

IN

The IN clause can be used to specify a folder where each inserted object should be located.  The folder is specified as a cPath.  For example:

INSERT INTO Contact SET Name='Jenny' IN /Example/Folder