-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No such function: REGEXP #60
Comments
The REGEXP is used to access a user defined function. I got some code from a stackoverflow answer, as below. I just found this minutes ago, and haven't yet used the regex search (middle of refactoring), but it did get rid of the exception. http://stackoverflow.com/questions/25786996/sqlite-query-with-regex Function.create(connection, "REGEXP", new Function() {
@Override
protected void xFunc() throws SQLException {
String expression = value_text(0);
String value = value_text(1);
if (value == null)
value = "";
Pattern pattern=Pattern.compile(expression);
result(pattern.matcher(value).find() ? 1 : 0);
}
}); |
It would be nice for this repo to publish Javadocs on github pages or wherever. E.g. its not obvious what the package for FYI http://javadox.com/org.xerial/sqlite-jdbc/3.8.11.2/org/sqlite/package-summary.html |
It seems regexp is not available even in the latest command line:
If sqlite-jdbc supports this, @everbeeks's approach is better, but this will be Java-style REGEXP syntax, and can be different behavior with the other sqlite distributions. |
Hi, |
SQLite itself doesn't provide any regexp implementation, so we need to register a UDF like #60 (comment) |
Hi , Trying to run this UDR , I got the error
What is wrong? Any tips? |
@xerial , please, how to register that? |
@ceinmart i've currently managed to configure it through a CustomDataSource and then using it as you like whenever needed. hope this helps |
So I'll chime in here with Good New / Bad News concerning the solution: Bad News, is that the solution is from Stack OverFlow, so it is covered by the Creative Commons Share Alike 4.0 License. If your code is going to be commercial in nature, I would strongly advise speaking to legal first. So... To the developers of sqlite-jdbc, please can you bake a solution into the driver? |
The SQLite grammar specification defines that there is support for usage of Regular expressions in any
expr
statement:The driver does not support this function:
A sample query:
This is a sample stacktrace, when preparing a statement:
The stacktrace is cut, all classes below the snippet are my classes.
I am using
org.xerial:sqlite-jdbc:3.8.11.2
straight from Maven Central.The text was updated successfully, but these errors were encountered: