SQlite: Count affected rows

Share your advanced PureBasic knowledge/code with the community.
dige
Addict
Addict
Posts: 1089
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

SQlite: Count affected rows

Post by dige »

If you need to know whether an DatabaseUpdate() has caused a change, you can query this as follows:

Code: Select all

Procedure.i Sqlite3_CountChanges (DBID)
  Protected SQL.S = "SELECT changes()", Result.l = -1
  
  If DatabaseQuery(DBID, SQL)
    If NextDatabaseRow(DBID)
      Result = GetDatabaseLong(DBID, 0)
    EndIf
    FinishDatabaseQuery(DBID)
  Else
    Debug DatabaseError()
  EndIf
  
  ProcedureReturn Result
EndProcedure
"Daddy, I'll run faster, then it is not so far..."
User avatar
Kiffi
Addict
Addict
Posts: 1177
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: SQlite: Count affected rows

Post by Kiffi »

Nice! :D

Thanks & Greetings ... Peter
Hygge
Post Reply