wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Emulate an SQL query statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Emulate an SQL query statement "Like" - Javascript API" Watch "Emulate an SQL query statement "Like" - Javascript API" New topic
Author

Emulate an SQL query statement "Like" - Javascript API

Reda Elboukfaoui
Greenhorn

Joined: Apr 02, 2013
Posts: 2

Hello everyone,

Actually I was wondering is it possible to emulate an SQL query statement as :
"LIKE %some keyword%"

I'm using a specific Javascript API (SuperGIS Server Javascript API) which is handling a query with the usual operators (= + - * / & Or...) through a method ExecuteQuery(pLayer, expr, bGeom)
with the expr as the query itself.

Actually, I have already got those operators which are being handled by default.

var oper = pNode.ownerDocument.createElement("select");
oper.options[0] = new Option("=", " = ");
oper.options[1] = new Option("<", " < ");
oper.options[2] = new Option(">", " > ");
oper.options[3] = new Option("<=", " <= ");
oper.options[4] = new Option(">=", " >= ");
oper.options[5] = new Option("!=", " != ");


oper.options[6] = new Option("Like", " like "); // the problem appears when I'm using this particular line which is not handled by the API itself.




RĂ©da ELBOUKFAOUI
GIS Specialist.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

You likely need to consult the APi documentation of that library. I've never heard of it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Reda Elboukfaoui
Greenhorn

Joined: Apr 02, 2013
Posts: 2

I'm trying to make it possible with Javascript.
But if the API doesn't contain or accept such a possibility ?What to do?
I found a way to do it on the internet through Regular expressions, but I'm not truly sure of how this is working :

RegExp.escape = function(text)
{
if (!arguments.callee.sRE)
{
var specials = [
'/', '.', '*', '+', '?', '|',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
}
return text.replace(arguments.callee.sRE, '\\$1');
}

fieldvalue.value = RegExp.escape(fieldvalue.value);
var match = new RegExp(fieldvalue.value.replace("%", ".*").replace("_", ".")).exec(m_inputFilter.value) != null;


http://stackoverflow.com/questions/1314045/emulating-sql-like-in-javascript
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Emulate an SQL query statement "Like" - Javascript API