Ask AI
Skip to main content

Fetch one from ext. database

Function: Fetch one from ext. database

This function allows you to retrieve a single record (a row of data) from an external database. You can specify which database to connect to, which table to query, and apply filters to find the exact record you need. The retrieved record can then be used in other parts of your application.

Input,

  • Database connection: Details required to connect to your external database.
    • Type: Choose the type of database you are connecting to (e.g., MSSQL, MYSQL).
    • Server: The address or hostname of your database server.
    • Database: The name of the specific database you want to access on the server.
    • User: The username for logging into the database.
    • Password: The password for the database user.
    • Port: The port number used for the database connection (e.g., 1433 for MSSQL, 3306 for MySQL).
  • Table: The name of the table in the external database from which you want to fetch a record.
  • Data format: (Optional) If you have defined a data structure in your application that matches the table you're querying, select it here. This helps in defining filters and understanding the output.
  • Filters: (Optional) Criteria to narrow down which record to fetch. You can add multiple filters.
    • Attribute: Choose a column (attribute) from your table to filter by.
    • Operator: Select how the attribute should be compared (e.g., "Equal", "Greater than", "Contains").
    • Value: Provide the value to compare against the chosen attribute.
  • Attributes: (Optional) If you only need specific columns from the record, select them here. If left empty, all columns will be fetched.

Output,

  • Result: The single record (object) fetched from the database that matches your criteria. This will contain all selected attributes and their values.

Execution Flow,

Real-Life Examples,

Example 1: Fetching a Customer by ID

Imagine you have a customer management system and want to display a specific customer's details when their ID is entered.

  • Inputs:
    • Database connection: (Type: MYSQL, Server: my-db.example.com, Database: CRM_DB, User: admin, Password: secure_password, Port: 3306)
    • Table: Customers
    • Data format: Customer_Data_Format (a pre-defined structure matching your Customers table)
    • Filters:
      • Attribute: CustomerID
      • Operator: Equal
      • Value: 12345 (the ID of the customer you want to find)
    • Attributes: (Leave empty to fetch all customer details)
  • Result: The application retrieves the full record for the customer with CustomerID 12345, which can then be displayed on a customer detail page.

Example 2: Finding a Product by Name and Price

Suppose you need to find a specific product in your inventory database, knowing its name and that its price is above a certain amount.

  • Inputs:
    • Database connection: (Type: MSSQL, Server: inventory-server, Database: Products_DB, User: inv_user, Password: prod_pass, Port: 1433)
    • Table: Products
    • Data format: Product_Data_Format
    • Filters:
      • Filter 1:
        • Attribute: ProductName
        • Operator: Equal
        • Value: Wireless Mouse X100
      • Filter 2:
        • Attribute: Price
        • Operator: Greater than
        • Value: 25.00
    • Attributes: ProductName, Price, StockQuantity
  • Result: The application fetches the record for "Wireless Mouse X100" if its price is greater than 25.00, providing only its name, price, and stock quantity.

Example 3: Retrieving a Pending Order for a Specific User

You want to find a single pending order placed by a particular user to review its details.

  • Inputs:
    • Database connection: (Type: MYSQL, Server: order-db.cloud.net, Database: Orders_System, User: order_manager, Password: order_secure, Port: 3306)
    • Table: Orders
    • Data format: Order_Data_Format
    • Filters:
      • Filter 1:
        • Attribute: OrderStatus
        • Operator: Equal
        • Value: Pending
      • Filter 2:
        • Attribute: UserID
        • Operator: Equal
        • Value: user_alpha_123
    • Attributes: OrderID, OrderDate, TotalAmount, OrderStatus
  • Result: The application retrieves the first pending order placed by user_alpha_123, including its ID, date, total amount, and current status.