                                  .replace('CONTAINS','~')
                                  .replace('MATCHES','~')
                                  .replace('ANY', '<@ array'));
-    
+
+      quoteIfString = function(arg) { 
+        if(typeof arg === 'string') { 
+          return "'" + arg + "'"; 
+        }
+
+        return arg;
+      }
+      
       if(parameters) {
-        for(var prop in parameters) {
-          var val = parameters[prop];
-        
-          if(typeof parameters[prop] === 'string') { 
-            val = "'" + parameters[prop] + "'" ;
-          } 
-
-          /* replace the value with token */
-          ret = ret.replace('{' + decamelize(prop) + '}', val);
+        if(ret.indexOf('%@') > 0) {  /* replace wild card tokens */
+          for(var prop in parameters) {
+            var n = ret.indexOf('%@'),
+                val =  quoteIfString(parameters[prop]);
+
+            ret = ret.slice(0, n) + val + ret.slice(n + 2);
+          }
+        } else {  /* replace parameterized tokens */
+          for(var prop in parameters) {
+            var param = '{' + decamelize(prop) + '}',
+                val = quoteIfString(parameters[prop]);
+            
+            ret = ret.replace(param, val);
+          }
         }
       }
     }

  return JSON.stringify(recs);

$$ language plv8;

select private.fetch('XM.Contact',E'{"parameters":{ 
                                       "firstName": "Jake", 
                                       "lastName": "F"
                                     }, 
                                     "conditions":"firstName = {firstName} OR lastName STARTS_WITH {lastName}", 
                                     "orderBy":"lastName"}', 3);
           .replace('{limit}', limit)
           .replace('{offset}', offset);
           
  if(debug) { print(NOTICE, 'sql = ', sql); }

  recs = executeSql(sql);

