Example: Display SQL Results from an External Database Macro

If you want to display SQL results from an external database in a table, you can easily accomplish this with a custom script macro.

For this example, we are going to use data from an external pet store database. To display a table with this store data, follow these steps: 

  1. Create a resource to configure an external database connection. 

    See External Database Connection for more information.
  2. Select the Create Macro button on the Macro page. 

  3. Select Custom Script Macro.
  4. Configure your custom script macro by filling out the following fields: 
    1. Keypet-store-table
    2. Name: Pet store database table
    3. Description: Table displaying SQL results from an external pet store database
    4. Body Type: None
    5. Output Type: Block
    6. Skip the Parameter section.
    7. Enter the following code for Macro Code

      An error occured

      There is a problem with the file path provided or a failure to connect with Bitbucket. Check the File Path provided, Application Link for Bitbucket Data Center or the permissions of the app password for Bitbucket Cloud. Contact your system administrator.


      For more information on MarkupBuilder and safe HTML, check out Security and Best Practices.

    8. Skip the Macro Javascript Code, Macro CSS Style, and Lazy Loaded fields. 
  5. Click Add
  6. View your new macro when the Macro page loads.

Result

When the macro is used on a page and the results load, it looks like the following image:

On this page