create table gps (
train integer
, gpstimestamp timestamp with time zone
, geom sdo_geometry
)
Table created.
insert into gps
select
-- Train 1 travels 1 unit per second in Z direction only
1
, timestamp '2020-01-01 00:00:00' + numtodsinterval(level, 'second')
, sdo_geometry(3001, null, sdo_point_type(1, 1, level), null, null)
from dual
connect by level <= 100
union all
select
-- Train 2 travels diagonally in X/Y/Z direction
2
, timestamp '2020-01-01 00:00:00' + numtodsinterval(level, 'second')
, sdo_geometry(3001, null, sdo_point_type(level, level, level), null, null)
from dual
connect by level <= 100
200 row(s) inserted.
commit
Statement processed.
ORA-22901 should not occur
select
train, gpstimestamp, geom
, nvl(sdo_geom.sdo_distance(geom, lag(geom) over (partition by train order by gpstimestamp), 0.005), 0) as prev_dist
from gps
ORA-22901: cannot compare VARRAY or LOB attributes of an object typeMore Details: https://docs.oracle.com/error-help/db/ora-22901
this work around is valid
select *
from (
select
train, gpstimestamp, geom, prev_dist
from gps
match_recognize (
partition by train
order by gpstimestamp
measures
nvl(sdo_geom.sdo_distance(geom, prev(geom), 0.005), 0) as prev_dist
all rows per match
pattern (any_row)
define
any_row as 1=1
)
)