Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL DOMAIN in MATCH_RECOGNIZE throws error

Mike KutzNov 11 2024

SQL DOMAIN throw ORA-6504 if used in the define clause of a match_recognize statement.

Database: 23.5 FREE (VirtualBox)

It works inside select clauses within a CTE (with ). It also works in a RAS Realm definition.

create domain tick_d as enum ( start_tick
							 , lap_tick 
							 , end_tick
);


with curr_time (ts) as (
	select systimestamp
),
make_ticks (tick, rn) as (
	-- THESE WORK !!!
	select tick_d.start_tick, interval '0' second union all
	select tick_d.lap_tick, interval '2' second union all
	select tick_d.lap_tick, interval '3' second union all
	select tick_d.lap_tick, interval '4' second union all
	select tick_d.lap_tick, interval '4.2' second union all
	select tick_d.end_tick, interval '13.5' second
), data (ts, tick ) as (
	select c.ts+m.rn, m.tick
	from curr_time c, make_ticks m
)
select * from data
MATCH_RECOGNIZE (
	order by ts

	MEASURES
		last( a_stop.ts ) - first( a_start.ts ) as total_time

	pattern ( a_start a_lap* a_stop )

	define 
		a_start as tick = 1,
		a_lap as tick = 2,
		a_stop as tick = tick_d.end_tick -- THIS FAILS !!!
	)
;
This post has been answered by mathguy on Nov 11 2024
Jump to Answer
Comments
Post Details
Added on Nov 11 2024
4 comments
182 views