繁体   English   中英

match_recognize 子句中动态模式量词的使用

[英]Dynamic pattern quantifier usage in match_recognize clause

示例查询:

select * from table
match_recognize (
  order by column1
  pattern (anything {**3**,}) 
  define
    anything as column1 = 'col'
);

考虑到我有一个表,我想找到遵循定义模式的连续行。 但是对于上面的示例,我正在寻找一种动态传递数字而不是传递 static 值 3 的方法。

我曾尝试使用绑定变量、子查询,但似乎没有任何效果。 有没有什么方法可以将相同的匹配识别查询与动态量词一起使用?

If any non-numeric literal is entered it is throwing this error.
SQL Error: ORA-62501: invalid value specified for bounded quantifier in MATCH_RECOGNIZE clause
62501. 00000 - "invalid value specified for bounded quantifier in MATCH_RECOGNIZE clause"

Oracle 版本:19c

如果有人遇到过这种情况,请您帮助我。 提前致谢。

MATCH_RECOGNIZE不允许您在模式匹配子句中使用动态值; 相反,您可以将查询编写为:

SELECT *
FROM   (
  SELECT t.*,
         COUNT(*) OVER () AS num_rows
  FROM   table_name
  WHERE  column1 = 'col'
)
WHERE  num_rows >= :required_rows

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM