This documentation supports the 11.3 version of BMC Discovery.

To view an earlier version of the product, select the version from the Product version menu.

SQL database integration

Centralized databases — asset databases, for example — are accessed with sql_integration definitions. The definitions block must contain a name setting.This setting corresponds to the Integration Point in the user interface. Each define block must contain a query setting that contains the SQL query to perform. Parameters are inserted into the query with the usual TPL % interpolation. For example:

definitions AssetDatabaseDetails 1.0
  """Queries to obtain information from asset database"""

  type := sql_integration;
  name := "Example asset database";
  define getLocationOfHost
    """Return details of the location for the given hostname"""

    parameters := hostname;
    query := """select name, address from hosts, locations where
                hosts.id_location = and hostname = %hostname%""";
  end define;

end definitions;

The defined function is used in a pattern as the function AssetDatabaseDetails.getLocationOfHost. It is called with a hostname parameter, followed by a connection parameter. This parameter refers to a connection created within the Integration Point. It returns a list of nodes, one for each row of output from the query. If the query fails in some way, the function returns none. Each row node has attributes named after the columns selected in the SQL query.


As some databases put all column names in uppercase or lowercase, BMC Discovery standardizes all result column names to lowercase. 

For example, to use the query defined above, use the following code:

location_rows := AssetDatabaseDetails.getLocationOfHost(hostname := host.hostname,
                                                        connection := $$connection_name$$;
if location_rows = none then
  log.warn('Could not retrieve location for host %host.hostname%');
end if;

for row in location_rows do
  // Create / update Location node for this location, 
  // with a key made from its name and address.
  loc := model.Location(name :=,
                        address := row.address,
                        key := "");
  // Relate the Location to the Host...
end for;
Was this page helpful? Yes No Submitting... Thank you