मुझे पता है कि यह एक पुराना सवाल है, लेकिन यदि आप जावा में कोडिंग कर रहे हैं और यह समस्या है तो यह सहायक हो सकता है। आप एक ऐसे फ़ंक्शन को पंजीकृत कर सकते हैं जो चेकिंग को संभालता है। मैं टिप प्रपत्र इस पोस्ट है: https://stackoverflow.com/a/29831950/1271573
समाधान SQLite JDBC पर मैं निर्भर: https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc
मेरे मामले में मैं केवल अगर एक निश्चित स्ट्रिंग (एक और स्ट्रिंग के भाग के रूप में अस्तित्व '% mystring% की तरह देखना चाहते थे '), इसलिए मैंने एक फंक्शन बनाया है, लेकिन इसे रेगेक्स या कुछ का उपयोग करके अधिक एसक्यूएल जैसी जांच करने के लिए इसे विस्तारित करना संभव होना चाहिए।
एसक्यूएल में फ़ंक्शन का उपयोग करने देखने के लिए अगर MyCol शामिल है "searchstring" आप क्या करेंगे:
select * from mytable where Contains(MyCol, 'searchstring')
यहाँ है मेरी शामिल समारोह:
public class Contains extends Function {
@Override
protected void xFunc() throws SQLException {
if (args() != 2) {
throw new SQLException("Contains(t1,t2): Invalid argument count. Requires 2, but found " + args());
}
String testValue = value_text(0).toLowerCase();
String isLike = value_text(1).toLowerCase();
if (testValue.contains(isLike)) {
result(1);
} else {
result(0);
}
}
}
इस सुविधा का उपयोग करने से पहले आपको रजिस्टर करना होगा यह। जब आप इसे इस्तेमाल करने के साथ कर लेंगे तो आप वैकल्पिक रूप से इसे नष्ट कर सकते हैं।
public static void registerContainsFunc(Connection con) throws SQLException {
Function.create(con, Contains.class.getSimpleName(), new Contains());
}
public static void destroyContainsFunc(Connection con) throws SQLException {
Function.destroy(con, Contains.class.getSimpleName());
}
स्रोत
2017-03-04 07:34:51
http://stackoverflow.com/a/973777/1427878 – CBroe