B4J Question SQL Statement Gooblygook??

Mashiane

Expert
Licensed User
Longtime User
Hi there

For some reason my sql commands include gooblygook when passed to my sql connection..

java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "update": syntax error)

B4X:
Dim jSQL As SQL = SQLGet
    
    'we have update statements, process them first.
    'Dim sqlCommands As List
    'sqlCommands.Initialize
    jSQL.AddNonQueryToBatch("update iymanalysisset set aprvar = aprproj - apract",Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set mayvar = mayproj - mayact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set junvar = junproj - junact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set julvar = julproj - julact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set augvar = augproj - augact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set sepvar = sepproj - sepact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set octvar = octproj - octact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set novvar = novproj - novact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set decvar = decproj - decact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set janvar = janproj - janact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set febvar = febproj - febact", Null)
    jSQL.AddNonQueryToBatch("update iymanalysisset set marvar = marproj - maract", Null)

How do I solve this issue, there is nothing wrong with my sql statements, they compute when ran externally however in my bj4 app, bam!!
 

Mashiane

Expert
Licensed User
Longtime User
It looks like an encoding issue. How is jSQL initialized? Which database are you using?

Thanks Erel, Im using SQLite as a backend, i just remembered something about unprintable characters, so I fired up Brackets and there was a red dot between the double quote and the update word, removed that and pasted back to the b4j IDE. Now it works! My Net++ for some reason didnt pick that up.

The error report now does make sense..

java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "update": syntax error)
 
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
As inakigarm said, you are missing quotes around your string values.
B4X:
jSQL.AddNonQueryToBatch("update iymanalysisset set aprvar = 'aprproj - apract'",Null)
 
Last edited:
Upvote 0
Top