Hello,
after updating to PB 4.20 I also changed my SQLite related code to the PB database commands. And after a few weeks since then, I have not mentioned any disadvantages. My first thought was as well, that I needed a function to get the number of rows of a result set, but I didn't.
Before the change I used Kiffi's SQLite3 include file, and it worked well. To browse through a result set I used For...Next loops, and with that you really need the row count. But now I changed all these loops to
While NextDatabaseRow(#DB)...Wend or
Repeat...Until NextDatabaseRow(#DB) = #False,
which I think is the better code. And as a bonus, you don't have to move to the next row, which I liked to forget in the For...Next loops, and then wondered, why it didn't finish.
When you really need the number of rows, a three line command sequence will do the job.
Code: Select all
DatabaseQuery(#DB, "SELECT COUNT(*) FROM Table")
FirstDatabaseRow(#DB)
lNumRows = GetDatabaseLong(#DB, 0)
What I really missed, was the column access by name.
Tp overcome this, I wrote a little procedure, which converts the column name to the related index.
Code: Select all
Procedure.l GetDBColIdx(sColNam.s)
Define lSI.l
For lSI = 0 To DatabaseColumns(#DB) - 1
If DatabaseColumnName(#DB, lSI) = sColNam
ProcedureReturn lSI
EndIf
Next
EndProcedure
Now a columns access looks like
Code: Select all
str1 = GetDatabaseString(#DB, GetDBColIdx("XXX"))
After all, I am very satisfied with the change, and perhaps the column access by name will be a function of a PB future release.