sqlite3 - Android SQLite queries marked as Error by Android Studio -


in 1 of android apps use sqlite queries starting give problems since i've updated android studio 3.0.

despite can compile , run app marked error.

these queries.

 db.execsql("insert table1 (…) ... substr(replace(table2.field2, ',', ''), table1.field1, 1) … table1 … …"); 

gives error in 'replace':

')' or expression expected, got 'replace'

i think work because replace returns string.

and:

db.execsql("delete table1 table1.rowid in (…)"); 

gives error in 'rowid':

column name or table name expected, got 'rowid'

i think work because sqlite adds implicit rowid each table.

and:

db.execsql("attach database ? newdb", new string[] { getdatabasepath(database_name_new).getpath() }); 

gives error in '?':

expression expected, got '?'

i've changed query this:

db.execsql("attach database '"+getdatabasepath(database_name_new).getpath()+"' newdb"); 

also:

db.execsql("update table1 set field1=0 field2 in  (select field2 table2 field3 '%blablabla%' or field4 '%blebleble%' or (field5 '%bliblibli%' , field6 not '%blobloblo%')  collate nocase)"); 

which gives these errors:

in 'field6 not like':

')' or '.' expected, got 'not'

in 'nocase)':

between, in or semicolon expected, got ')'

i don't know wrong one.

are these queries correct? in ios identical , working well.

update:

these full queries (unfortunately due client's security policy have change name of tables , fields, hope ok detect errors).

db.execsql("insert table1 (field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14) " +                     "select t6.field1, t7.field2, t3.field4, t3.field5, case when t5.field1='1' '11' " +                     "when t5.field1='2' '22' when t5.field1='3' '33' when t5.field1='4' '44' " +                     "else t5.field1 end newfield1, t4.field1, case when t2.field1 = '0' t4.field2 " +                     "else substr(replace(t4.field3, ',', ''), t2.field1, 1) end newfield2, t2.field4, '0', -1, '0', '1', -1, t8.field1 " +                     "from table2 t2, table3 t3, table4 t4, table5 t5, table6 t6, table7 t7, table8 t8 " +                     "where t2.field2=t3.field3 , t2.field3=t4.field1 , t2.field3=t5.field2 , t3.field2=t7.field2 , " +                     "t3.field1=t6.field1 , substr(t5.field1, 1, 1) in ('1', '2', '3', '4') , substr(t5.field1, 2, 1) in ('1', '2', '3', '4') , t2.field5=t8.field2");  db.execsql("delete table1 table1.rowid in (select table1.rowid table1, table4 t4 table1.field6=t4.field1 , (((t4.field2 not '%%' || substr(table1.field5, 1,1) || '%%') , (t4.field3 not '%%' || substr(table1.field5, 1,1) || '%%')) or ((t4.field2 not '%%' || substr(table1.field5, 2,1) || '%%') , (t4.field3 not '%%' || substr(table1.field5, 2,1) || '%%'))))");  db.execsql("attach database ? newdb", new string[] { getdatabasepath(database_name_new).getpath() }); changed to: db.execsql("attach database '"+getdatabasepath(database_name_new).getpath()+"' newdb"); , error gone.  db.execsql("update table1 set field13=1 field2 in (select t7.field2 table7 t7 t7.field1='text1' or t7.field1='text2' or t7.field1 '%text3%' or t7.field1 '%text4%' or t7.field1 '%text5%' or t7.field1 '%text6%' or (t7.field1 '%text7%' , t7.field1 not '%text8%') collate nocase)"); 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -