Skip to content
Advertisement

Oracle Regular Expression (REGEXP_LIKE) Too Long Error – ORA-12733

I have to validate an IPv6 address in PL/SQL. I came up with the regular expression from here: Regular Expression (RegEx) for IPv6 Separate from IPv4

I am getting an ORA-12733: regular expression too long error. Is there any way around this?

The limit is 512 (https://stackoverflow.com/a/2694119/3112803), I’m at 657. I cannot think of any way to split this up.

Is importing a java class into Oracle the only way? https://community.oracle.com/thread/1149462?start=0&tstart=0

UPDATE: I’m trying this but when I run the select to test it, it throws ORA-29531: no method isProperIPv6Address in class ipv6. I haven’t messed with java in Oracle before so I’m not sure if I’m close or if this is a bad idea. (taken from https://community.oracle.com/message/8648095)

It does appear that java.net.Inet6Address.getByName() will literally go out to the internet and see if this address really exists. Am I understanding that correctly? I don’t need that. I just need to verify that they syntax is valid.

Advertisement

Answer

Replace your long regexp ^regexp1|regexp2|...$ with logical OR of many short regexps:
if ( REGEXP_LIKE(v,'^regexp1$') OR REGEXP_LIKE(v,'^regexp2$') OR ... ) then

UPDATE:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement