Update an ext. database
Function: Update an external database
This function allows you to modify existing records in an external database connected to your platform. You can specify which records to update by setting up filters and then provide the new information to be applied to those records. This is useful for keeping your external data synchronized or making bulk changes without writing any code.
Input
- Database connection: This is the specific connection you've set up to your external database (e.g., a connection to your CRM database or an inventory system).
- Table: The name of the specific table within your connected database where you want to update records. For example,
CustomersorProducts. - Data format: This defines the structure of the data you are working with in the chosen table. It helps the platform understand what kind of information (e.g., text, numbers, dates) is in each column.
- Filters: (Optional) A set of conditions that determine which records in the table will be updated. If you don't specify any filters, all records in the table will be updated with the provided data.
- Attribute: The specific column in your table that you want to check against.
- Operator: How the attribute should be compared to the value (e.g., "Equal to", "Greater than", "Contains").
Equal: Matches records where the attribute is exactly the same as the value.Greater than: Matches records where the attribute's value is numerically or chronologically larger than the specified value.Greater than or equal: Matches records where the attribute's value is numerically or chronologically larger than or equal to the specified value.In: Matches records where the attribute's value is one of several specified values.Less than: Matches records where the attribute's value is numerically or chronologically smaller than the specified value.Less than or equal: Matches records where the attribute's value is numerically or chronologically smaller than or equal to the specified value.Not equal: Matches records where the attribute is not the same as the value.Not in: Matches records where the attribute's value is not among several specified values.Contains: Matches records where the attribute (text) includes the specified value.Contains \(ignore case\): Matches records where the attribute (text) includes the specified value, without considering uppercase or lowercase.Starts with: Matches records where the attribute (text) begins with the specified value.Ends with: Matches records where the attribute (text) finishes with the specified value.
- Value: The specific data you want to compare the attribute against.
- Data: The new information you want to apply to the selected records. This should be provided as a JSON object, where the keys match the column names in your table and the values are the new data for those columns.
Output
This function does not return any direct output to your application. Its primary effect is to modify the records in your external database.
Execution Flow
Real-Life Examples
Here are a few examples of how you might use the "Update an external database" function:
Example 1: Updating a customer's email address
Imagine you have a Customers table in your external CRM database, and a customer has updated their email address.
- Inputs:
- Database connection:
MyCRMDatabase - Table:
Customers - Data format:
CustomerSchema(defines fields likeCustomerID,Email,Name) - Filters:
- Attribute:
CustomerID - Operator:
Equal - Value:
12345
- Attribute:
- Data:
\{
"Email": "[email protected]"
\}
- Database connection:
- Result: The record for the customer with
CustomerID12345in yourCustomerstable will have itsEmailfield updated to[email protected].
Example 2: Marking all pending orders as "Processing" for a specific region
You have an Orders table and want to change the status of all orders that are currently "Pending" and originated from the "North" region.
- Inputs:
- Database connection:
SalesDatabase - Table:
Orders - Data format:
OrderSchema(defines fields likeOrderID,Status,Region) - Filters:
- Filter 1:
- Attribute:
Status - Operator:
Equal - Value:
Pending
- Attribute:
- Filter 2:
- Attribute:
Region - Operator:
Equal - Value:
North
- Attribute:
- Filter 1:
- Data:
\{
"Status": "Processing"
\}
- Database connection:
- Result: All records in the
Orderstable where theStatusisPendingAND theRegionisNorthwill have theirStatusfield updated toProcessing.
Example 3: Increasing the price of all products in a certain category
You want to apply a 10% price increase to all products in the "Electronics" category in your Products table. (Note: This example assumes your database can handle calculations or you've pre-calculated the new price in your application logic before calling this function).
- Inputs:
- Database connection:
InventoryDatabase - Table:
Products - Data format:
ProductSchema(defines fields likeProductID,Category,Price) - Filters:
- Attribute:
Category- Operator:
Equal - Value:
Electronics
- Operator:
- Attribute:
- Data:
(Assuming the original price was 100.00 and you've calculated the new price before passing it here. If you need to perform calculations directly in the database, you might need a different action or a stored procedure.)
\{
"Price": 110.00
\}
- Database connection:
- Result: All records in the
Productstable where theCategoryisElectronicswill have theirPricefield updated to110.00.