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

Discussion in 'Android Questions' started by Javier Campo Martinez, May 22, 2018.

  1. Javier Campo Martinez

    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
     
  2. DonManfred

    DonManfred Expert 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...
     
  3. Javier Campo Martinez

    Javier Campo Martinez Member Licensed User

    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,
     
  4. fredo

    fredo Active Member Licensed User

    Did you try

    Code:
    select changes() as xval
    as documented here?
     
  5. DonManfred

    DonManfred Expert Licensed User

    Javier Campo Martinez likes this.
  6. Javier Campo Martinez

    Javier Campo Martinez Member Licensed User

    @DonManfred @fredo
    It works!!!
    This is my piece of code:
    Code:
    Sub ActualizarCodVerificacion(iCodigo As Int, iUsuario As String, iEmail As StringAs 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: May 22, 2018
    DonManfred and fredo like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice