Result<Record2<BigInteger, DayToSecond>> record = create 

.select( 

   TEST.ID, timestampDiff(TEST.ARRIVAL, lag(TEST.DEPARTURE).over().orderBy(
TEST.ID)).as("time_diff") 

       ).from(TEST) 

.orderBy(TEST.ID) 

.fetch();

Hi,


I am testing the query above. But I found 2 difficulties:


1.) timestampDiff only takes TIMESTAMP columns as parameters. But mostly we 
are working with Oracle's DATE types. These are not working here. Would it 
be possible to overload the timestampDiff method for the DATE types?

2.) I am using an alias to rename the new calculated column - because it is 
has a new semantic meaning and a new data type. But now jOOQ is losing the 
type safety. On fetching I have to do an explicit type cast to DayToSecond 
if I want to fetch the "time_diff" column:

        for (int i = 0; i < record.size(); i++) {
            Record2<BigInteger, DayToSecond> entry = record.get(i);
            DayToSecond timeDiff = (DayToSecond)entry.get("time_diff");
            System.out.println(entry.get(TEST.ID) + ": " + (timeDiff != null 
? timeDiff.getTotalMinutes() : null));
        }

Is there a better way?


Greets, Mark

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