Insert Data using X++

Rumman Ansari   Software Engineer   2024-10-17 06:06:51   114  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

You can use SQL statements, either interactively or in source code, to insert one or more rows into tables that are stored in the database.

  • insert method – Insert one row at a time. Click here for more details.
  • doInsert method – Insert one row at a time.
  • insert_recordset statement – Copy multiple records directly from one or more tables into another table in one database trip. Click here for more details.
  • RecordInsertList.insertDatabase – Insert multiple rows at the same time in one database trip. Use this construct when you don't have to sort the data.Click here for more details.
  • RecordSortedList.insertDatabase – Insert multiple rows at the same time in one database trip. Use this construct when you want a subset of data from a specific table, and you want that data to be sorted in an order that doesn't currently exist as an index.

RecordSortedListRecordInsertList, and insert_recordset let you insert multiple records. By using these methods, you reduce communication between the application and the database. Therefore, you help increase performance. In some situations, record set–based operations can fall back to record-by-record operations. For more information, see Conversion of operations from set-based to record-by-record.


doInsert method

The doInsert method generates values for the RecId field and other system fields, and then inserts the contents of the buffer into the database. Use this method when the insert method on the table must be bypassed.

 Warning

A call to doInsert skips all logic, including database event handlers (for example oninserting and oninserted), chain-of-command onInsert(), and the insert() call itself. It's generally considered bad practice to use doInsert, and we don't recommend that you use it.