US and Worldwide: +1 (866) 660-7555
Results 1 to 6 of 6

Thread: Parameter in Select declaration of SQL QUERY using JDBC

  1. #1
    Join Date
    Aug 2012
    Posts
    25

    Default Parameter in Select declaration of SQL QUERY using JDBC

    Hi i have a problem using a parameter into select declaration

    I have created a radio button with a parameter declared. I have to use this parameter to execute the query with a determinated colum(bytes,flows). This parameter is returned with string value

    I have this SQL query and consult t.bytes or t.flows but it doesn´t work:

    SELECT s.nombre elem, sum(t.${data}) val
    FROM TAGR_5M_SUB t, trad_appgroup s
    WHERE t.elemento = s.id AND t.id_agregado = 5 AND t.id_vista = ${view}
    and t.fecha >= str_to_date(CONCAT(${dateIni},' 00:00'),'%Y-%m-%d %H:%i')
    and t.fecha < str_to_date(CONCAT(${dateFin},' 23:59'),'%Y-%m-%d %H:%i')
    GROUP BY s.nombre
    ORDER BY 2 asc

    I tried use CONCAT like in fecha WHERE clause but it wasn´t correct


    Any idea to do this?

    Thanks

  2. #2
    Join Date
    Mar 2011
    Posts
    257

    Default

    Hey there.

    CDA uses prepared statements to execute the SQL queries. and these do not allow you to use parameters in select,group by, order by clause.
    so there are 2 options using a union and an extra where clause to select 1 of the 2 unions. or 2 separate queries and change the datasource when changing the radio button.
    (you can also look around this forum a bit there are more people who had your problem.)

    Greetz,
    Hans

  3. #3
    Join Date
    Aug 2012
    Posts
    25

    Default

    Thanks @hansva.. i would have to change it in the post change of my radio button. Isn´t it?.

    But i have read something for the property "render_Chartname.queryDefinition.dataAccessId" but i don´t understand it. I haven´t found more information.

    Could you tell me more about it?

    Thanks a lot
    Alberto

  4. #4
    Join Date
    Mar 2011
    Posts
    257

    Default

    If you open up a javascript debugger and load you dashboard. you will be able to see that the datasource is indeed defined under dataAccessId.
    This is a string pointing to the correct CDA datasource (the same string you use in the CDE editor to point to the correct query)
    by manipulating that string in the post fetch and then triggering an render_Charname.update() it will use the other query.

  5. #5
    Join Date
    Aug 2012
    Posts
    25

    Default

    Yes i have seen this declaration:

    var render_pie_chart = { type: "cccPieChart", name: "render_pie_chart", chartDefinition: {

    width: 400, height: 400, dataAccessId: "ds_pie_chart_bytes",
    .............
    postFetch: function () { alert("after "+render_pie_chart.dataAccessId); }

    I manipulates this string at post change of the Radio button component with this:
    function changeData(){
    var cadDataSource="ds_bar_chart_"+data;
    render_pie_chart.dataAccessId = cadDataSource;
    alert(render_pie_chart.dataAccessId);
    render_pie_chart.update();
    }

    The alerts show me that the dataAccessId changes but the result of the chart it´s the same. Always uses the first declaration.

    I uses render_Charname.update(). Why is showing the same?

  6. #6
    Join Date
    Aug 2012
    Posts
    25

    Default

    Thanks for the replies. I change the declaration from postFech to preExecution of the chart:

    function changeData(){
    var cadDataSource="ds_bar_chart_"+data;
    render_bar_chart.chartDefinition.dataAccessId = cadDataSource;
    }

    And it works. I hope it can help someone.

    I ´ve found it here: http://forums.pentaho.com/showthread...in-a-CCC-chart

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •