Highlighted
Respected Contributor.
Respected Contributor.
378 views

uCMDB API and parametrized queries

Jump to solution

Hi everyone,

 

this is my first post on HP boards and I have a question about uCMDB and saved parametrized queries.

 

First, let me know if there is a more convenient forum/board for this question than the current one.

 

So, what I am trying to do is to build a parametrized query with a IN condition on the global id and pass it a list/collection of ids to get a selected portion of the structure of interest using the Java API. I have all my non-parametrized queries working just fine as well as those using the method addValue() to set a single value instead of a collection of values.

 

Unfortunately I am getting a server-side ExecutionException and I am seeking for hints to debug this problem.

 

Is the IN condition expecting a single parameter string with all the ids concatenated and separated by a comma? Or is it supposed to accept a collection of values as shown below?

 

Here is the snippet of code passing the arguments to the parametrized query:

 

        String qName = "My saved query name";
        ExecutableQuery myquery = dr.get(qName).toExecutable();
        QueryParameters params = myquery .queryParameters();
        params.addValues("list_of_ids", ids);
        Topology result = tqs.executeQuery(myquery );

 

Where ids is Collection<String> of ids converted to strings with the method getAsString() from the UcmdbId object.

 

TIA
 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Respected Contributor.
Respected Contributor.

Re: uCMDB API and parametrized queries

Jump to solution

Since my question has triggered a tremendous participation I believe it worth provide the answer for the benefit of the crowd.

 

You can actually simply use addValue() with a Collection/List, there is no need to use addValues() for that specific purpose. The question is left open, hence, why addValues() shouldn't be considered obsolete and removed from the API since it adds simply no further functionality to addValue() and just confuse guys like me?

View solution in original post

0 Likes
1 Reply
Highlighted
Respected Contributor.
Respected Contributor.

Re: uCMDB API and parametrized queries

Jump to solution

Since my question has triggered a tremendous participation I believe it worth provide the answer for the benefit of the crowd.

 

You can actually simply use addValue() with a Collection/List, there is no need to use addValues() for that specific purpose. The question is left open, hence, why addValues() shouldn't be considered obsolete and removed from the API since it adds simply no further functionality to addValue() and just confuse guys like me?

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.