B4J Question [SOLVED]Transaction committed, but data not inserted into table

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have a problem, my app inserted data into 2 tables, but when committed, data only inserted in 1 table.

Here are my codes
B4X:
Sub InsSls(IdTrs As Int,IdInOtSP As Int,IdCnt As Int,Dt As String,FrmN As String,IdGd As Int,IdGift As Int,Prc As Int,IdDsc As Int,Qty As Int,Dscp As String,InpBy As String) As Boolean
    Private Rsl As Boolean
    Private InsQry As SQL
    Private IdInOt1,IdInOt2 As Int
    Private Brt,Nt,Dsc As Double
    Private SPV As String
   
    InsQry = dbpool.GetConnection
    InsQry.BeginTransaction
    Try
        IdInOt1 = GetId1(IdCnt,Dt,IdTrs)
        SPV     = GetSpv(IdCnt)
       
        If IdInOt1 = 0 Then
            IdInOt1 = GetId
            InsQry.ExecNonQuery2("insert into t_in_ot1 (id,id_trs_typ,id_cst_sppl,trs_dt,dscp,inp_by,lck_by,spv) values(?,?,?,?,?,?,?,?)", _
                              Array As Object(IdInOt1,IdTrs,IdCnt,Dt,"Sales From Android",InpBy,InpBy,SPV))
        End If
           
        IdInOt2 = GetId
   
        Brt    = Qty*Prc
        If IdDsc = 0 Then
            Dsc = 0
            Nt = Brt
        Else
            Dsc = GetDsc(IdDsc)
            Nt  = Brt*(100-Dsc)/100
        End If
   
        If IdGift = 0 Then
            InsQry.ExecNonQuery2("insert into t_in_ot2(id,id_in_ot1,lnk_id,frm_n,id_gd,prc,prc_dsc1,qty,brt,nt,unt,dscp) values(?,?,?,?,?,?,?,?,?,?,?,?)", _
                          Array As Object(IdInOt2,IdInOt1,IdInOtSP,FrmN,IdGd,Prc,Dsc,Qty,Brt,Nt,"PSG",Dscp))

        Else
            InsQry.ExecNonQuery2("insert into t_in_ot2(id,id_in_ot1,lnk_id,frm_n,id_gd,id_gift,prc,prc_dsc1,qty,brt,nt,unt,dscp) values(?,?,?,?,?,?,?,?,?,?,?,?,?)", _
                          Array As Object(IdInOt2,IdInOt1,IdInOtSP,FrmN,IdGd,IdGift,Prc,Dsc,Qty,Brt,Nt,"PSG",Dscp))
        End If
       
        InsQry.TransactionSuccessful
        Rsl = True
    Catch
        Log(LastException)
        Rsl = False
    End Try
               
    InsQry.Close
    Return Rsl
End Sub

App runs without an error, but data only inserted in table t_in_ot1, while on table t_in_ot2, no data inserted.

Where am I missing?
Note : B4J 6.01, java 1.8_092 64 bit.
 

incendio

Well-Known Member
Licensed User
Longtime User
Found the problem.

It turn out that 1 trigger on the other table that deleted inserted records on table t_in_ot2.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…