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!

REGEXP > 512 bytes

d55606b8-a11f-4022-a1b6-eea56911333aJul 31 2012 — edited Aug 1 2012
As there's a limit of 512 bytes on the input of a regular expression pattern, I was wondering if there was any clever way around this?

Take the following example:
WITH t1
     AS (SELECT 'this is phrase 1 this is phrase 2 this is phrase 3 ' phrase
         FROM   DUAL
         UNION
         SELECT 'this is phrase 2 this is phrase 1 this is phrase 3 ' phrase
         FROM   DUAL)
SELECT *
FROM   t1
WHERE  REGEXP_LIKE(phrase, 'this is phrase 1 this is phrase 2 this is phrase 3 ');
This is fairly self-explanatory; we get the correct row returned. But suppose the REGEXP_LIKE pattern to be used was large, and we split it up into 3 (or more) sections, at appropriate points. It can't simply be used with AND as in this example:
WITH t1
     AS (SELECT 'this is phrase 1 this is phrase 2 this is phrase 3 ' phrase
         FROM   DUAL
         UNION
         SELECT 'this is phrase 2 this is phrase 1 this is phrase 3 ' phrase
         FROM   DUAL)
SELECT *
FROM   t1
WHERE  REGEXP_LIKE(phrase, 'this is phrase 1 ')
AND    REGEXP_LIKE(phrase, 'this is phrase 2 ')
AND    REGEXP_LIKE(phrase, 'this is phrase 3 ');
because then it doesn't know that the 3 sections of the pattern need to be in order, and hence all rows are returned.

Is there any way around this? e.g. getting the end position of the first phrase to use as the start point of the second phrase, hierarchies, etc.?

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2012
Added on Jul 31 2012
7 comments
2,275 views