Hi Everybody
I'm trying to set date('now') using dbutils in a sqllite db.
I've some problem the date('now') seems to be resolved as string instead of a date function.
Maybe the issue is the SqlLite itself.
If I look to the value in datacreazione field i find the litteral Date('now') instead of yyyy-mm-dd...
B4X:
Dim ListOfMaps As List
ListOfMaps.Initialize
Dim m As Map
m.Initialize
m.Put("Id", Main.codpratica)
m.Put("cognome", edittext1.text)
m.Put("nome", edittext2.Text)
m.Put("tipo",edittext3.text)
m.Put("tag",edittext4.Text)
m.Put("datacreazione", "Date('now')")
m.Put("livello",Main.livello)
m.Put("utente",Main.userx)
ListOfMaps.Add(m)
DBUtils.InsertMaps(Main.SQL, "pratiche", ListOfMaps)
Does anybody have the same problem. I could extract the value for date but this is a too simple workaround!!!
I think it's probably a problem with DBUtils and not SQLite. It's perfectly possible to do an INSERT command with a date function in SQLite. Does your SQLite column have it's affinity set as DateTime or Date?
I think it's probably a problem with DBUtils and not SQLite. It's perfectly possible to do an INSERT command with a date function in SQLite. Does your SQLite column have it's affinity set as DateTime or Date?
DBUtils creates a prepared statement with the values you pass to it. The values will be inserted to the database as is (no need to escape anything). If you need to call a SQL function then you need to create the statement instead of using InsertMaps.
I have traced the DBUtils and seems to do the job. The Date('now') function is correctly inserted in INSERT statement. So the issue must be elsewhere... This is not a problem, since I can build the SQL INSERT on my own or pass the date as a value. This is the first time I use SQL Lite, so it's more an exercize for me than a real need. In MsSQL and MySql I use the date function on almost every DB to mark the creation date of each row, for future needs.
Thank you everybody. You are a high valued group!