moster67 Expert Licensed User Longtime User Nov 16, 2015 #1 I am not very proficient with databases so I thought I would ask for your help with some code related to SQLite. I could have posted this in the B4j section as well but I thought it was easier here. It is related to the B4xPushServer and my table-structure (with pseudo-values) is as follows: Code: Copy token = E6XXXXXXXXXXXXXXXXXXX type = 1 updated_time = 1447672514961 freqpref = 180 This is the code I modified from the B4xPushServer: Code: Copy Dim rows As List = DBUtils.ExecuteMemoryTable(Main.db, _ "SELECT * FROM tokens WHERE updated_time > ?", _ Array As String (DateTime.Now + (freqpref*1000)), 0) In the quoted code, 'freqpref' will not work of course. Instead I need to read the value of 'freqpref' from the DB. Like this: Code: Copy Dim rows As List = DBUtils.ExecuteMemoryTable(Main.db, _ "SELECT * FROM tokens WHERE updated_time > ?", _ Array As String (DateTime.Now + (180*1000)), 0) Can someone help with this code?
I am not very proficient with databases so I thought I would ask for your help with some code related to SQLite. I could have posted this in the B4j section as well but I thought it was easier here. It is related to the B4xPushServer and my table-structure (with pseudo-values) is as follows: Code: Copy token = E6XXXXXXXXXXXXXXXXXXX type = 1 updated_time = 1447672514961 freqpref = 180 This is the code I modified from the B4xPushServer: Code: Copy Dim rows As List = DBUtils.ExecuteMemoryTable(Main.db, _ "SELECT * FROM tokens WHERE updated_time > ?", _ Array As String (DateTime.Now + (freqpref*1000)), 0) In the quoted code, 'freqpref' will not work of course. Instead I need to read the value of 'freqpref' from the DB. Like this: Code: Copy Dim rows As List = DBUtils.ExecuteMemoryTable(Main.db, _ "SELECT * FROM tokens WHERE updated_time > ?", _ Array As String (DateTime.Now + (180*1000)), 0) Can someone help with this code?
LucaMs Expert Licensed User Longtime User Nov 16, 2015 #2 Probably you cannot use DBUtils in this case. You should use the "classic" command: Code: Copy Dim Query As String = "SELECT * FROM tokens WHERE updated_time > (" & DateTime.Now " & " + ( freqpref * 1000)) " Dim Cur As Cursor = Main.db.Exec... If Cur... For r = 0 to Cur.RowCount - 1 Cur.Position = r ... Next Upvote 0
Probably you cannot use DBUtils in this case. You should use the "classic" command: Code: Copy Dim Query As String = "SELECT * FROM tokens WHERE updated_time > (" & DateTime.Now " & " + ( freqpref * 1000)) " Dim Cur As Cursor = Main.db.Exec... If Cur... For r = 0 to Cur.RowCount - 1 Cur.Position = r ... Next
moster67 Expert Licensed User Longtime User Nov 16, 2015 #3 Thank you Luca. However, my logic in my previous query was completely wrong so I had to re-write it anyway and this time it works. Upvote 0
Thank you Luca. However, my logic in my previous query was completely wrong so I had to re-write it anyway and this time it works.