InsertData()
Inserts rows into a data extension, and returns the number of rows inserted.
Use this function in CloudPages, landing pages, microsites, and SMS messages in Mobile Connect. Use the InsertDE()
function to insert rows into a data extension from emails.
The InsertData()
function has three parameters:
dataExt
(string): Required. The name of the data extension that you want to insert data into.columnName1
(string): Required. The name of the column to insert into the data extension.valueToInsert1
(string): Required. The value to insert into the specified column.
You can insert multiple values into a row by appending column names and field values to the end of the function.
To use the function, first pass it the name of the data extension that you want to insert data into. Next, pass it the name of the column to insert data into. Finally, pass the data that you want to insert into the specified column.
Imagine you have a Flights data extension that contains the data in this table.
FlightId | Origin | Dest | Price | PerBagSurcharge |
---|---|---|---|---|
1 | IND | NYC | 100 | |
2 | IND | LAX | 200 | |
3 | IND | SEA | 500 | 25 |
To insert a new row, use this function.
The function inserts the specified row. The data extension now contains this data.
FlightId | Origin | Dest | Price | PerBagSurcharge |
---|---|---|---|---|
1 | IND | NYC | 100 | |
2 | IND | LAX | 200 | |
3 | IND | SEA | 500 | 25 |
4 | IND | ORD | 125 |
The function returns 1
, indicating that it inserted one row.