Posts

Showing posts with the label sql

How do I create a Field from a value T in jOOQ, explicitly?

16 1 In jOOQ, it is easy to use bind variables in expressions like: MY_TABLE.COL.eq(1); MY_TABLE.COL.in(1, 2, 3); MY_TABLE.COL.between(1).and(10); All of the above methods accept both T and Field<T> types, e.g. Field.eq(T) or Field.eq(Field<T>) . But what if I want to put the bind variable on the left side of the expression? These obviously don't work: 1.eq(MY_TABLE.COL); 1.in(MY_TABLE.COL1, MY_TABLE.COL2, MY_TABLE.COL3); 1.between(MY_TABLE.COL1).and(MY_TABLE.COL2); How can I turn those 1 or "xyz" into Field<Integer> or Field<String> , etc.? (This is such a popular question on the jOOQ mailing list, etc., so I'm documenting it here) java sql jooq ...

Aggregate Overlapping Segments to Measure Effective Length

I have a road_events table: create table road_events ( event_id number(4,0), road_id number(4,0), year number(4,0), from_meas number(10,2), to_meas number(10,2), total_road_length number(10,2) ); insert into road_events (event_id, road_id, year, from_meas, to_meas, total_road_length) values (1,1,2020,25,50,100); insert into road_events (event_id, road_id, year, from_meas, to_meas, total_road_length) values (2,1,2000,25,50,100); insert into road_events (event_id, road_id, year, from_meas, to_meas, total_road_length) values (3,1,1980,0,25,100); insert into road_events (event_id, road_id, year, from_meas, to_meas, total_road_length) values (4,1,1960,75,100,100); insert into road_events (event_id, road_id, year, from_meas, to_meas, total_road_length) values (5,1,1940,1,100,100); insert into road_events (event_id, road_id, year, from_meas, to_meas, total_road_length) values (6,2,2000,10,30,100); insert into road_events (event_id, road_id, year, from_meas, to_meas...