DBUtils misses first field

Phantomco

Member
Licensed User
Longtime User
Hey all,

Think I need a fresh set of eyes to tell me what's up with this. The first field (dbid) does not get entered into the database but it does show up in the list just fine. All other fields are fine.
This is using the standard insertmaps, first pulled from an external database. dbid is numeric but result shows as null:

Dim parser As JSONParser
parser.Initialize(res)
Select TaskId
Case InspectionList
Dim irqs As List
irqs = parser.NextArray 'returns a list with maps

For i = 0 To irqs.Size - 1
Dim m As Map
m = irqs.Get(i)
ListView1.AddSingleLine2( m.Get("dbid") & m.Get("permitnum")& "-" & m.Get("street") & "-" & m.Get("insprequest"),m.Get("dbid"))
Next
'writing to local db
DBUtils.InsertMaps(ldata, "inspupload", irqs)
ProgressDialogHide​

Thanks!

Mike
 

Phantomco

Member
Licensed User
Longtime User
Interesting. It's dropping the first field. Although it errors out, it stll adds the remainder of the records correctly.

InsertMaps (first query out of 83): INSERT INTO [inspupload] (, [phone], [ptypestring], [streetno], [inspector], [status], [contractor], [oname], [insprequest], [reqtime], [done], [street], [reqdate], [reqby], , [dbid], [permitnum], [ptype], [inspcomment]) VALUES (, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)


[quote="Erel, post: 114470"]Can you post the log message that appears when you call this method?

It should start with: "InsertMaps (first query out of ..."[/QUOTE]
 
Upvote 0

Phantomco

Member
Licensed User
Longtime User
Anyone have any thoughts on this? The first field is a serialized number but the list control is picking it up correctly prior to it's being inserted in the database...

Thanks

Mike
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
From what I see, the 'dbid' field is not appearing as the first field. BUT it does show up in the query, it's positioned 4th from the end. Perhaps you should check your code for parsing data, maybe you have a null field in the beginning other than the dbid.
Oh, and another thing. Reading the dbUtils code a bit, did you perhaps accidentally change this piece of code of the dbUtils module?
B4X:
If i2 > 0 Then
                    columns.Append(", ")
                    values.Append(", ")
                End If
 
Upvote 0

Phantomco

Member
Licensed User
Longtime User
Good catch MC, thanks. That's why I needed another set of eyes to look at this.

It seems that the "select *" statement getting the data from the server isn't sending the data in the same order as it is in the postgres db.

So, I guess the best way is to redo the select with the field names in the correct order, which would be less code than writing an INSERT with all the .get.
 
Upvote 0
Top