Jump to content
We've recently updated our Privacy Statement, available here ×

using parameter for optional clause


rossi_jeff

Recommended Posts

 I'm trying to repoduce in a report results from my application. The app send the following params

$P{include} = false

$P{start_time} = '17:00:00'

$P{end_time} = '22:00:00'

 

In my report I added this parameter

$P{daily_clause}

default value:

new String(($P{include} == true) ? "" : " AND (TIME(readings.`created_at`)>'" + $P{start_time}.toString() + "' OR TIME(readings.`created_at`)<'" + $P{end_time}.toString() + "')")

 

And my query

SELECT

     readings.`id` AS readings_id,

     readings.`speed` AS readings_speed,

     readings.`device_id` AS readings_device_id,

     readings.`created_at` AS readings_created_at,

     readings.`event_type` AS readings_event_type,

     readings.`street_number` AS readings_street_number,

     readings.`street` AS readings_street,

     readings.`place_name` AS readings_place_name,

     readings.`admin_name1` AS readings_admin_name1,

     devices.`id` AS devices_id,

     devices.`name` AS devices_name

FROM

     `readings` readings INNER JOIN `devices` devices ON readings.`device_id` = devices.`id`

WHERE

     readings.`device_id` = $P{device_id}

 AND readings.`created_at` BETWEEN $P{start_date} AND $P{end_date} $P!{daily_clause}

 

I printed ${daily_clase} in a cell and it looks correct but has no effect on the query.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

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...