× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

SQLiteException near "<" while delete query

Xaver Kapeller
May 07, 2015
<p>When using parameterised queries you need to specify where you want the parameters to be inserted into your query. You do this by adding a <code>?</code> where the parameter is supposed to go. Now look at the query in the exception and it becomes pretty obvious what is wrong:</p> <pre><code>DELETE FROM engine_utilization_report WHERE unix_time &lt; </code></pre> <p>Notice the <code>unix_time &lt;</code> at the end? The <code>?</code> is missing. The correct query should look like this:</p> <pre><code>DELETE FROM engine_utilization_report WHERE unix_time &lt; ? </code></pre> <p>To fix the error you just need to add the <code>?</code> at the end of the where clause like this:</p> <pre><code>dbUtilsObj.delete(EngineUtiReport.TABLE_NAME, EngineUtiReport.Columns.KEY_ENGINE_UTI_UNIX_TIME + DBUtils.IS_LESS_THAN + "?", new String[] { String.valueOf(nDaysOldUnixTime) }); </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/30002187/SQLiteException%20near%20%22&lt;%22%20while%20delete%20query/30002222">Stack Overflow</a>.</p>
comments powered by Disqus