Hi
My application creates a cursor from a SQL select statement:
I want to right this cursor to a csv file. I have tried to do this two ways, with the Text Writer:
I then tried to do the same thing with WriteList
In both instances curResult is 262 rows in length, and in both instances the output file stop halfway through row 239. What is happening to the missing rows?
Probably worth mentioning that in both instances the for loop is executed 262 times, and List_stock contains 262 rows also.
Thanks
Dave
My application creates a cursor from a SQL select statement:
B4X:
cSQL = "SELECT all Stock.id as Id, Stock.record_type as Record_Type, sum(Stock_Take.qty) as Qty FROM Stock_take JOIN Stock ON Stock_Take.id = Stock.id GROUP BY Stock.id UNION ALL SELECT Stock.id, Stock.Record_Type, 0 FROM Stock where Stock.id not in (select DISTINCT Stock_Take.id from stock_take) order by record_type, id"
curResult = dbSQL.ExecQuery(cSQL)
I want to right this cursor to a csv file. I have tried to do this two ways, with the Text Writer:
B4X:
oTextWriter.Initialize(File.OpenOutput(tcFolder, tcFile, lAppend))
curResult.Position=I
oTextWriter.Write(curResult.GetString("Id") & ",")
oTextWriter.Write(curResult.GetString("Record_Type") & ",")
oTextWriter.Write(curResult.GetString("Qty") & ",")
oTextWriter.WriteLine("")
Next
oTextWriter.Flush
oTextWriter.Close
I then tried to do the same thing with WriteList
B4X:
Dim List_Stock As List
Dim cID, cRecord_Type, cQty As String
Dim cStock_item As String
List_Stock.Initialize
'
For I = 0 To curResult.RowCount-1
curResult.Position=I
cID = curResult.GetString("Id")
cRecord_Type = curResult.GetString("Record_Type")
cQty = curResult.GetString("Qty")
cStock_item = cID & "," & cRecord_Type & "," & cQty & ","
List_Stock.add(cStock_item)
next
File.WriteList(tcFolder,tcFile,List_Stock)
In both instances curResult is 262 rows in length, and in both instances the output file stop halfway through row 239. What is happening to the missing rows?
Probably worth mentioning that in both instances the for loop is executed 262 times, and List_stock contains 262 rows also.
Thanks
Dave