Platform.Function.UpdateDE()
Updates data in a data extension, and returns the number of rows updated.
You can use this function to update data in a data extension in an email. Use the Platform.Function.UpdateData() function to update rows in CloudPages, landing pages, microsites, and SMS messages in MobileConnect.
Ordinal | Type | Description |
---|---|---|
1 | String | Required. The name of the data extension that contains the data to update. |
2 | Array | Required. An array that contains the column names to search for a matching value. |
3 | Array | An array that contains values to filter on. |
4 | Array | Required. An array that contains that names of the columns to update. |
5 | Array | Required. An array that contains the new values for the specified columns. |
To use the function, first pass it the name of the data extension that contains the data you want to update. Next, pass it an array of the columns to search to find the row that you want to update and optionally an array that includes the values that identify the row to update. Finally, pass it an array that contains the names of the columns that you want to update the data in and an array that contains the updated values for those columns.
In this example, a data extension called "Flights" contains the data in this table.
FlightId | Origin | Dest | Price | PerBagSurcharge |
---|---|---|---|---|
1 | IND | NYC | 100 | |
2 | IND | LAX | 200 | |
3 | IND | SEA | 500 | 25 |
4 | ORD | SEA | 525 | 10 |
5 | ORD | LAX | 400 | |
6 | SEA | SAN | 300 | |
7 | SEA | ATL | 10 | |
8 | ATL | AUS | 350 | 10 |
9 | STL | KCA | 5 | |
10 | IND | ATL | 125 |
To update the Price
value for FlightId
10, use this function.
The function returns 1
, indicating that it updated one 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 | ORD | SEA | 525 | 10 |
5 | ORD | LAX | 400 | |
6 | SEA | SAN | 300 | |
7 | SEA | ATL | 10 | |
8 | ATL | AUS | 350 | 10 |
9 | STL | KCA | 5 | |
10 | IND | ATL | 316 |
You can use the Platform.Function.UpdateDE()
function to update more than one column in a single row in one operation. To update multiple columns, you must provide one set of search criteria for each column that you want to update.
This example uses a data extension called "Flights2" 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 |
Use this code to update the Dest
, Price
, and PerBagSurcharge
fields for FlightId
1.
The function returns 1
, indicating that it updated one row. The data extension now contains this data.
FlightId | Origin | Dest | Price | PerBagSurcharge |
---|---|---|---|---|
1 | IND | JFK | 75 | 10 |
2 | IND | LAX | 200 | |
3 | IND | SEA | 500 | 25 |