You can translate the question and the replies:

Adding Logic to Join View

Hello, I am having some issues designing a solution to a feature that I need to create. Scenario: I have a data set with a specific field that needs to be modified when a condition true is passed in from the web service and not modified when a condition false is passed in from the web service. This modification MUST occur on the server, not the client. Example (not my exact problem, but I am using it for simplicities sake): I have a name field which I would like to order "last, first middle" when I pass true to a specific field of the web service. But when I pass false to a specific field in the web service, I want the order to be "first middle last". My solution to this problem was to add a "boolean" mock field to the selection of the data set in my service view. Then, expose that mock field in the webservice that will query the data set. However, this method does not appear to be working as whenever I pass in false to the mock field, it does not return any results. This makes sense as I am querying the data set with false on the mock field and there are no values in that field. Question: Is there a way to add logic to the vql of the JOIN view that can change the query based on whether I pass a specific value to the web service that references the JOIN view? Any help would be appreciated. Thanks, Nate
user
14-09-2017 11:42:08 -0400

1 Answer

Hi, For this scenario, I would do the following steps: 1. In the derived view, create a new field that splits the data of the desired field using 'SPLIT' function that will return an array. 1. Create a Selection view over the derived view and define a View parameter as Boolean type which is used to pass the values at runtime. 1. Add a new field with a field expression with the combination of 'case' and 'concat' function. The 'concat' function concatenates arrays into one string based on the position of the array index and 'case' would perform the ordering based on the input of the boolean view parameter. 1. On executing this view, I would get the expected results. For more information, you can have a look at the following sections [Creating a Selection view](https://community.denodo.com/docs/html/browse/6.0/vdp/administration/creating_views/creating_derived_views/creating_selection_views), [SPLIT function](https://community.denodo.com/docs/html/browse/6.0/vdp/vql/appendix/syntax_of_condition_functions/text_processing_functions#split) and [CASE clause](https://community.denodo.com/docs/html/browse/6.0/vdp/vql/queries_select_statement/case_clause/case_clause). Hope this help!
Denodo Team
18-09-2017 08:47:01 -0400
You must sign in to add an answer. If you do not have an account, you can register here