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

Thread: Dynamic Table Name in report query

  1. #1
    Join Date
    Jan 2008
    Posts
    7

    Default Dynamic Table Name in report query

    Using PRD 3.6, is it possible to create a query with a dynamic table name?

    For e.g. select * from ${table_name} . Where "table_name" would be a report parameter. Report parameter substitution seems to work everywhere in the query except when using it in the "FROM" clause. Can someone verify?

  2. #2
    Join Date
    Jul 2007
    Posts
    2,172

    Default

    16:50 < Kaapa> andresF: no can do
    16:50 < Kaapa> unless you pass the entire query, params have to be stuff you can use in prepared statements
    16:50 < Kaapa> not the table
    16:50 < Kaapa> you could use a kettle trans for it
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  3. #3
    Join Date
    Mar 2003
    Posts
    7,560

    Default

    Bah! Use the "Advanced SQL datasource" and the following expression on the report's query attribute

    ="SELECT * FROM " & [table_name]

    That will allow you to parametrize the query even on places where prepared parameters would not be allowed.

    Also see Michael Tarallos Guide to Guided Adhoc Reporting for a live demo of that technique.
    http://www.sherito.org/2010/11/demos...n-pentaho.html
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  4. #4
    Join Date
    Nov 1999
    Posts
    678

    Default

    Thomas,

    Did you mean "Advanced/JDBC (Custom)" ?

  5. #5
    Join Date
    Mar 2003
    Posts
    7,560

    Default

    Yes. That one.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  6. #6
    Join Date
    Aug 2011
    Posts
    2

    Default

    How do i do that for a parameter...?

  7. #7
    Join Date
    Mar 2003
    Posts
    7,560

    Default

    Before PRD-3.9: You dont.

    After: Use the integrated scripting that comes with all major datasources.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

Posting Permissions

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