Ask AI
Skip to main content

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, Customers or Products.
  • 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 like CustomerID, Email, Name)
    • Filters:
      • Attribute: CustomerID
      • Operator: Equal
      • Value: 12345
    • Data:
      \{
      "Email": "[email protected]"
      \}
  • Result: The record for the customer with CustomerID 12345 in your Customers table will have its Email field 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 like OrderID, Status, Region)
    • Filters:
      • Filter 1:
        • Attribute: Status
        • Operator: Equal
        • Value: Pending
      • Filter 2:
        • Attribute: Region
        • Operator: Equal
        • Value: North
    • Data:
      \{
      "Status": "Processing"
      \}
  • Result: All records in the Orders table where the Status is Pending AND the Region is North will have their Status field updated to Processing.

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 like ProductID, Category, Price)
    • Filters:
      • Attribute: Category
        • Operator: Equal
        • Value: Electronics
    • Data:
      \{
      "Price": 110.00
      \}
      (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.)
  • Result: All records in the Products table where the Category is Electronics will have their Price field updated to 110.00.