Jump to content

Passing table name in SQL from control


rehara

Recommended Posts

Hi All,

My search on this topic have not gone well so I hope someone here may have some insight.

I have highly partitioned data. The partition logic is off loaded to the clients for speed.

I'm attempting to use the tool chain iReport->JasperServer to interact with this data.

The data is bulk time series stuff.

I have successfully created a report with a control to gather the required table name from the user.

The Query:

select $P{parameter1} as series, value, dt from  lrw_1_speed where dt > now() - interval '1 hour';

Produces the expect results.

But what I want is:

select $P{parameter1} as series, value, dt from  $P{parameter1}  where dt > now() - interval '1 hour';

 

The following error is reported by the PostgreSQL server ( 8.2.4 ):

ERROR:  syntax error at or near "$2" at character 37
STATEMENT:  select $1 as series, value, dt from $2 where dt > now() - interval '1 hour';
 

This fails too:

select fred as series, value, dt from  $P{parameter1}  where dt > now() - interval '1 hour';

Suggestions?

 

Thanks.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...