With SQLite, user defined SQL functions can easily be added using the C api or PHP. But is it also possible using Java or Groovy?
Simple way to create a function which accepts arguments and return result:
Function.create(conn, "addNS", new Function() {
@Override
protected void xFunc() {
System.out.println("myFunc called!");
String arg1;
try {
arg1 = value_text(0);
System.out.println("function arg1:"+arg1);
result("NS-"+arg1);
} catch (SQLException e) {
e.printStackTrace();
}
}
}, 1, Function.FLAG_DETERMINISTIC);
rs = conn.createStatement().executeQuery("select addNS('xyz');");
while(rs.next()) {
String val = rs.getString(1);
System.out.println("Function return val : " + val);
}