jSqliteCursor and jSqliteDataAccess case sensitive problem lazarus / 43-Android ---------------------------------------------------------------------- dseligo · 2024-07-01 02:23 Consider table created like in SQlite like this: 'create table mytable (myvalue integer)', that contains some positive integers. If I select them and use jSqliteCursor's method to get values like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i somevar := myCursor.GetValueAsInteger('MyValue')I will get -1, although there are no negative numbers in the table. That is because column names supplied to 'GetValueAs...' methods of jSqliteCursor and jSqliteDataAccess are treated as case sensitive. SQlite itself is ignorant of case in column names, but Java function getColumnIndex in the Cursor class treat column names as case sensitive. Problem is that 'GetValueAs...' methods return -1 (or empty string for GetValueAsString) in case that supplied case doesn't match one in the SQlite table. That is also true if you try to get values from non- existent columns. I suggest that exception is created in this case or that getColumnIndexOrThrow is used in the underlying Java code instead of getColumnIndex. ---------------------------------------------------------------------- jmpessoa · 2024-07-01 02:33 QuoteI suggest that exception is created in this case or that getColumnIndexOrThrow is used in the underlying Java code instead of getColumnIndex..... Can you put here the  code to fix this issue? Thank you! ---------------------------------------------------------------------- dseligo · 2024-07-10 01:23 Here is how I fixed issue for GetValueAsInteger. If you say this is correct, I will prepare and post fixes for other cursor methods too. This is GetValueAsInteger function on Java side (in fpc-lazarus\ccr\la mw\android_wizard\smartdesigner\java\jSqliteCursor.java): Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     public int GetValueAsInteger(String colName) {        if (mCursor == null) return -1;         int columnIndex = mCursor.getColumnIndex(colName);         if ((columnIndex < 0) || (columnIndex >= mCursorColumnCount) ||                (mCursorPos  < 0) || (mCursorPos >= mCursorRowCount)) return -1;         return mCursor.getInt(columnIndex);    } Here is how I propose to change this function, so that it raises exceptions: Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     public int GetValueAsInteger(String colName) {        if (mCursor == null)        throw new IllegalArgumentException("Cursor is null.");         int columnIndex = mCursor.getColumnIndexOrThrow(colName);         if ((columnIndex < 0) || (columnIndex >= mCursorColumnCount) ||              (mCursorPos  < 0) || (mCursorPos >= mCursorRowCount))          throw new IllegalArgumentException("Illegal column index or cursor position.");         return mCursor.getInt(columnIndex);    } Change is also needed at the end of function jni_func_t_out_i (in fpc- lazarus\ccr\lamw\android_bridges\androidwidget.pas) - otherwise exception is just 'swallowed' here: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   _exceptionOcurred:  If jni_ExceptionOccurred(env) then    raise Exception.Create(exceptionInfo); // I added this line I attached my testing app.