Skip to main content Skip to complementary content

Looking up values in a database

Create a map and use a DatabaseLookup function to get values from a database.

Before you begin

  • You have created an input and an output structure.
  • You have created a connection to your database.

About this task

In this example, two nearly identical JSON files are mapped and one element needs to retrieve its value from a database.

Procedure

  1. In the Hierarchical Mapper, right-click Maps and click New > Map.
  2. Select Standard Map and click Next.
  3. Select a folder and enter a name for your map, then click Finish.
  4. Drag your input and output structures in the map.
  5. Map your elements.

    Example

    In this example, you can drag the input order root on the output order to automatically map all the elements present in both structures.

  6. In the Functions tab, select General > DatabaseLookup and drag it to the Value tab of the country_code element.
  7. In the window that opens, select the database column from which you want to retrieve a value, then click OK.

    Example

  8. Add a condition. If you want to get the country code that matches the country in the input structure, for example, configure it as follows:
    1. Drag an Equal function on the Condition.
    2. Drag the input country element on the First Value.
    3. Drag a DatabaseColumn function on the Second Value.
    4. Select the database column containing the name of the country, NICENAME in this example.

    Example

Results

Your map is now configured and you can test it with a sample document using the Test Run option. In this example, the result looks like this:

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!