Android Question B4A SQL get number of records affected by UPDATE transaction

Javier Campo Martinez

Member
Licensed User
Hi guys !!!
Is there any way ( through the SQL library) to obtain the number of records affected by an UPDATE transaction over a database? ( no matter if it's Oracle|SQLite|MySql|etc...) without querying the database.

Thanx in advance.

Javier
 

DonManfred

Expert
Licensed User
Upvote 0

Javier Campo Martinez

Member
Licensed User
How do you expect to get this work?
The SQL Library does not have ANY Information about the Datasets in the Database, except you query the DB...

Hi @DonManfred ... !!!!

First of all, thanks for your kind answer ... i noticed that it was not possible ( i took a look at the SQL librarý's properties )

i.e., Oracle has the sentence SQL%ROWCOUNT to get the records affected by a INSERT|UPDATE|DELETE.

Anyway i had to ask it.

Best regards,
 
Upvote 0

Javier Campo Martinez

Member
Licensed User
@DonManfred @fredo
It works!!!
This is my piece of code:
B4X:
Sub ActualizarCodVerificacion(iCodigo As Int, iUsuario As String, iEmail As String) As Boolean
    Dim contador As Int
 
    Main.objBBDD.BeginTransaction
    Try
        'Execute the sql statements.
        Main.objBBDD.ExecNonQuery2("update usuarios set cod_verificacion=? where userid=? and email=?",Array As Object(iCodigo,iUsuario,iEmail))
        contador=Main.objBBDD.ExecQuerySingleResult("select changes() as xval")
        Main.objBBDD.TransactionSuccessful
        If contador=0 Then
            miResultado=false
        Else
            miResultado=true
        End If
     
    Catch
        miResultado=False
    End Try
    Main.objBBDD.EndTransaction
    Return miResultado
End Sub

Very very thank you !!!!

Best regards,
 
Last edited:
Upvote 0
Top