Hello fellow Jooqers

  I'm trying to use bindings to create an interval literal that I'm using 
in a where clause. Here is some context...

I have a bunch of records with timestamps and I'm trying to get the ones 
from the last *n *days.

Below is the intended SQL:

SELECT *

WHERE stuff.timestamp >= NOW() - '30 day'::INTERVAL

OR

SELECT *
FROM stuff
WHERE stuff.timestamp >= NOW() -  INTERVAL '30 day'

...same difference


In my Java code I'm doing something like this:


d.select(  field("date_trunc('hour', timestamp)").as("ts_hourly"),field(
"recordid") )
 .from(    table("stuff") )
 .where(condition("timestamp >= NOW() - '{0} day'::INTERVAL", val(days)))
 .fetch().stream()
  ...


The *where* condition is not binding the *days* variable to* {0}* 
(presumably because its in a string literal).  How do I create a dynamic 
interval using JOOQ without ugly string concatenation  ?


-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to