Pentaho

 View Only

 MySQL query with simple parameter

  • Pentaho
  • Pentaho
Sylvain LE MAT's profile image
Sylvain LE MAT posted 05-19-2018 08:18

Hi Guys,

First, I'm on Pentaho CE 8.0. And I'm not an expert on Pentaho.

The question seems simple but I cannot get it work. I'm trying for a dashboard to use a simple parameter for a WHERE condition in a MySQL query. The Bootstrap layout has 3 columns, one for each component (filter, text, table).

Simple parameter:

Name: salesrep_selection

Property value: mike

Filter component (to select the sales rep):

Name: salesrep_selection_filter

Parameter: salesrep_selection

Values Array: [["mike","Mike"],["paul","Paul"],["peter","Peter"]]

Value as Id: false

Text component: (just to check that the parameter is set up)

Name: selection_show_text

Listeners: ["salesrep_selection"]

Expression: function() {return this.dashboard.getParameterValue("salesrep_selection");}

Table component (customers list by sales rep):

Name: customers_list_table

Listeners: ["salesrep_selection"]

Datasource: customers_list_data

Datasource (MySQL query):

Name: companies_list_data

Jndi: business_datawarehouse

Query: SELECT customerid,customername FROM customers WHERE salesrep=${salesrep_selection}

Parameters: [] (empty)

 

When I start the dashboard, I get my selection list with the sales reps names. When I choose one, the id is displayed in the text component, but the table remains empty "No data available in table".

 

If I hard code the condition "WHERE salesrep='mike'", I get the list of customers.

With the parameter "WHERE salesrep=${salesrep_selection}", the MySQL query log shows me that it gets "WHERE salesrep=null". So the parameter is not sent to the query.

 

I also tried to set up the datasource parameters with [["salesrep_selection","salesrep_selection"]], but the table remains empty "No data available in table", and the MySQL query log shows "WHERE salesrep='salesrep_selection'".

 

I searched a lot on internet, not a lot of articles about this, but anyway, what I found is exactly what I implemented. And I don't get anything working.

 

Are the parameters handled differently in Pentaho CE 8.0? The queries parameters too?

 

Thank you in advance for your advices.


#Pentaho
Data Conversion's profile image
Data Conversion

Pentaho CDE SQL Query with numerical param  might help you sort out the issue.  Specifically Andre Jorge's  response at the end of the thread.

a a's profile image
a a