B4J Question Push data to webserver

elitevenkat

Active Member
Licensed User
Longtime User
hi
i have developed a commercial UI b4j desktop app for restaurants using jrdc . i want to synchronise the local data base and the database i had deployed in a web server..

i tried the following method to achieve this:

run a jrdc in the webserver.
in local system, an UI application is run with a timer to select the records appended and inserted into the webserver database.

i have control table in the local database containing the table names that are to be synchronised.

i open that table using mysql driver directly and loop thru and select the records from the mentioned table and perform the inserts/update/delete for the database in the web.


the problem is, the system seems to hung after displaying the label values and stops working.

what is wrong in the code ?

is there any other method to do this?

guidance required please.





B4X:
 private Sub WebUpdsIsert
   
    Dim rsTbl As ResultSet
   
   
    If blnConnected=False Then
      fx.Msgbox(MForm,"Not conected to localhost","Mysql")
    End If
   
     rsTbl  = sqlDb.ExecQuery("select * from web2updtables  where active=1")   
   
    Do While rsTbl.NextRow  
       Dim rsData As ResultSet  
        
        Dim nCols As Int =rsData.ColumnCount-2
       
        Dim cCmd As String="insert_" & rsTbl.GetString2(1)
        Dim lstCmd As List
        lstCmd.Initialize
       
        lblTable.Text=rsTbl.GetString2(1)
        Dim nRecs As Double
        Dim i As Int
        Dim blnGotrecs As Boolean=False
        Dim lKeys As List
        lKeys.Initialize
 
       Do While rsData.NextRow
         
          Dim cParm(nCols) As Object
          Dim ct2 As String
          For i=0 To nCols-1
             
               
             ct2=rsData.GetString2(i)
                           
             If ct2 <> Null Then
                ct2=ct2.trim
             End If
             
               
              cParm(i)=ct2  

             If i=0 Then
                lKeys.Add(ct2)
             End If
               
          Next
           If rsData.GetInt("webupdated")=0 Then
              cCmd ="insert_" & rsTbl.GetString2(1)
            Else
               cCmd ="update_" & rsTbl.GetString2(1)
            End If
           nRecs=nRecs+1
            lblRead.Text=nRecs
               
            Dim cmd As DBCommand
       
            cmd.Initialize
            cmd.Name =cCmd ' "insert_billhead"
                   
            cmd.Parameters = cParm ' Array As Object(cParm)
           
           
            lstCmd.Add(cmd)
           blnGotrecs=True
           
        Loop

        If blnGotrecs Then 
            Dim tParm As String =""
           For i=0 To cParm.Length-1
             tParm=tParm & cParm(i) & ","
             
            Next
            Log(tParm)
            Dim m As Map
            m.Initialize
            m.Put(rsTbl.GetString2(1),"WEB_INSERT")
            m.Put(rsTbl.GetString2(2),lKeys)
           
           rm.ExecuteBatch(lstCmd, m)
        End If
     Loop
    
 End Sub


B4X:
Sub JobDone(Job As HttpJob)
   
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
        Job.Release
    Else
        If Job.JobName = "DBRequest" Then
            Dim i As Int
            Dim result As DBResult = rm.HandleJob(Job)
       
'''           If Job.Tag = "WEB_INSERT" Then
'''                lblDone.Text=lblRec
'''          End If
            Dim m As Map=Job.Tag
   
            If m.GetValueAt(0) = "WEB_INSERT" Then
              '  Log("from job done " & m.GetkeyAt(0))
            tmr.Enabled=False     
            lblTable.Text= m.GetKeyAt(0)
            lblRead.Text=result.Rows.Size 
        ''    Log(rsTbl.GetString2(1))
             Dim lrst As List=m.GetValueAt(1)
            Log( "update " & m.GetKeyAt(0) & "set webupdated=1  where " & m.GetKeyAt(1))
            For i=0 To lrst.Size-1
              '  Log( "update " & m.GetKeyAt(0) & "set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) )   
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) )   
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webmodify=0  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) )   
                lblDone.Text=i+1
                'Log( "Key " & lrst.Get(i))                   
            Next
            tmr.Enabled=True
            Job.Release
            Return
          End If 


         If Job.Tag = "WEB" Then
               For Each row() As Object In result.Rows
                 
                 Createreset(row(0))
                 
             Next
           
          End If


Sub JobDone(Job As HttpJob)
   
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
        Job.Release
    Else
        If Job.JobName = "DBRequest" Then
            Dim i As Int
            Dim result As DBResult = rm.HandleJob(Job)
       
'''           If Job.Tag = "WEB_INSERT" Then
'''                lblDone.Text=lblRec
'''          End If
            Dim m As Map=Job.Tag
   
            If m.GetValueAt(0) = "WEB_INSERT" Then
              '  Log("from job done " & m.GetkeyAt(0))
            tmr.Enabled=False     
            lblTable.Text= m.GetKeyAt(0)
            lblRead.Text=result.Rows.Size 
        ''    Log(rsTbl.GetString2(1))
             Dim lrst As List=m.GetValueAt(1)
            Log( "update " & m.GetKeyAt(0) & "set webupdated=1  where " & m.GetKeyAt(1))
            For i=0 To lrst.Size-1
              '  Log( "update " & m.GetKeyAt(0) & "set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) )   
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) )   
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webmodify=0  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) )   
                lblDone.Text=i+1
                'Log( "Key " & lrst.Get(i))                   
            Next
            tmr.Enabled=True
            Job.Release
            Return
          End If 


         If Job.Tag = "WEB" Then
               For Each row() As Object In result.Rows
                 
                 Createreset(row(0))
                 
             Next
           
          End If

config commands

B4X:
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.

#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/test_web?characterEncoding=utf8
#JdbcUrl=jdbc:mysql://http://117.193.8.131//rainbow?characterEncoding=utf8
#JdbcUrl=jdbc:mysql://192.168.0.7/epos?characterEncoding=utf8
User=root
Password=XXXX
#Java server port
ServerPort=17280
##

sql.insert_arap=insert into arap (arappckey,arapdate,sourcepcksy,sourcedoctype,refpckey,refdoctype,debtorpckey,amount,drcr,openingrecord,openingrefdetails) values (?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_backuphead=insert into backuphead (backuppckey,backuppath) values (?,?)  
sql.insert_billlinetaxes=insert into billlinetaxes (billlinepckey,billpckey,taxpckey,amount) values (?,?,?,?)  
sql.insert_fontmaster=insert into fontmaster (fontpckey,fontname,active) values (?,?,?)  
sql.insert_itemrates=insert into itemrates (ratepckey,itempckey,posareapckey,rate,issueuom,issueconversionmeasure,rateeffectivefrom,active,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?)  
sql.insert_billlineitems=insert into billlineitems (billlinepckey,billpckey,kotnumber,kottime,itempckey,qty,rate,openitemname,measurepckey,reamarks,imeno,pactive) values (?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_debtormaster=insert into debtormaster (debtormaster,debtorname,contactphoneno,address,active) values (?,?,?,?,?)  
sql.insert_combooptions=insert into combooptions (combopckey,itempckey,optionno,options,active) values (?,?,?,?,?)  
sql.insert_cbilllinetaxes=insert into cbilllinetaxes (billlinepckey,billpckey,taxpckey,amount) values (?,?,?,?)  
sql.insert_indentissueline=insert into indentissueline (indentissuelinepckey,indentheadpckey,ingredientspckey,indentqty,remarks,autorizedby,authorizeddatetime,authorizedqty,authorizatoinremarks,issuedqty,issuedby,issuedon,issueremarks,receivedqty,receivedon) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_bomline=insert into bomline (bomlinepckey,bomheadpckey,ingredientpckey,qty,uom) values (?,?,?,?,?)  
sql.insert_complementdiscountncline=insert into complementdiscountncline (linepckey,cdncpckey,linediscription,active) values (?,?,?,?)  
sql.insert_itemgroupmaster=insert into itemgroupmaster (itemgrouppckey,groupname,itemcategorypckey,kitchenpckey,vegnv,baritem,outsourced,combo,taxable,active,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_itemmaster=insert into itemmaster (itempckey,itemcode,grouppckey,itemname,alphacode,active,uompckey,defaultissueuom,menudisplayorder,discountallowed,rate1,rate2,stockin,issued,vendorrate,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_devicelocation=insert into devicelocation (pckey,waiterpckey,lat,lon,dttime,billpckey) values (?,?,?,?,?,?)  
sql.insert_terminalhead=insert into terminalhead (terminalpckey,terminalname,touchpos,location,active,rkotallowed,cckey,lupd) values (?,?,?,?,?,?,?,?)  
sql.insert_taxstructuremaster=insert into taxstructuremaster (taxstructurepckey,taxpckey,applyorder,fromslabamount,toslabamount,slabcharge,active) values (?,?,?,?,?,?,?)  
sql.insert_ingredientgroups=insert into ingredientgroups (ingredientsgrouppckey,groupname,expense,active) values (?,?,?,?)  
sql.insert_uommaster=insert into uommaster (uompckey,uomdescription,posareapckey,active,cckey,lupd) values (?,?,?,?,?,?)  
sql.insert_deletedkots=insert into deletedkots (pckey,kotno,kotdatetime,deleteddatetime,tableno,waitername,itempckey,qty,reasonfordeletion,sessioncode,captainname,posareapckey,stnono,pax,nc,cckey) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_cbillhead=insert into cbillhead (billpckey,billno,billdate,serverdate,posareapckey,tablepckey,waiterpckey,pax,captainpckey,billbasicamount,billtaxes,billdiscount,billroundoff,billnetamount,settlementpckey,cancelled,reasonforcancellation,hmscheckinpckey,debtorpckey,remarks,reprintcount,nc,ncamount,hdpckey,sessionpckey,ldiscount,dbpckey,terminalpckey,deliverysettle) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_itempreference=insert into itempreference (itempreferencepckey,description,itempckey,active) values (?,?,?,?)  
sql.insert_indentauthorize=insert into indentauthorize (pckey,authdatetime,usercode,indentissuelinepckey,authqty,remarks) values (?,?,?,?,?,?)  
sql.insert_captainmaster=insert into captainmaster (captainpckey,captainname,captainshortname,posareapckey,active,pw,defaultcaptain,cckey,lupd) values (?,?,?,?,?,?,?,?,?)  
sql.insert_complementdiscountnchead=insert into complementdiscountnchead (cdncpckey,description,active) values (?,?,?)  
sql.insert_posarea=insert into posarea (posareapckey,posareaname,localstno,cstno,directbill,printkot,headernotes,footernotes,billprefix,billsuffix,dailystartwithbillno1,promptkotprint,promptbillprint,noofkotcopies,noofbillcopies,homedelivery,hmslinked,hmstccode,tallylinked,tallysaleshead,netratefactor,active,getcaptain,gettable,getwaiter,getkotnumber,getpax,getgroup,getnumericcode,getalphacode,currentsessionpckey,barpos,smslink,defaultwaiterpckey,defaultcaptainpckey,defaultsettlementpckey,touch,lh,promptforsettlement,pendingsettlementcode,checkstock,hmstc,printkotafterbill,defailttablepckey,getphone,openitemgroup,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_issueline=insert into issueline (issuepckey,issuetype,issuedatetime,indentissuelinepckey,issuedqty,rtnqty) values (?,?,?,?,?,?)  
sql.insert_numbermasterstores=insert into numbermasterstores (pckey,doctype,nextnumber) values (?,?,?)  
sql.insert_purchasertn=insert into purchasertn (pckey,rtndate,purchaselinepckey,qty,remarks,usercode) values (?,?,?,?,?,?)  
sql.insert_waitermaster=insert into waitermaster (waiterpckey,waitername,posareapckey,waitershortname,allinallposarea,active,mobileno,lon,lat,defaultwaiter,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_sessionmaster=insert into sessionmaster (sessionpckey,sessionname,fromtime,totime,posareapckey,active,nextsession,cckey,lupd) values (?,?,?,?,?,?,?,?,?)  
sql.insert_tabmaster=insert into tabmaster (tabid,tabkey,tabimeno,active) values (?,?,?,?)  
sql.insert_suppliermaster=insert into suppliermaster (supplierpckey,suppliername,supplieraddress,cstno,vat,phone,contactperson,active) values (?,?,?,?,?,?,?,?)  
sql.insert_settleline=insert into settleline (settlelinepckey,settleheadpckey,settlemasterpckey,settlementamount,remarks) values (?,?,?,?,?)  
sql.insert_tmpstock=insert into tmpstock (pckey,itempckey,groupname,itemname,opening,openingrate,openingvalue,purchase,purchaserate,purchasevalue,issue,issuerate,issuevalue,wastage,wastagerate,wastagevalue,closingstock,closingstockrate,closingstockvalue) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_kots=insert into kots (kotlinepckey,kotnumber,tablepckey,kotdatetime,itempckey,rate,qty,measurepckey,openitemname,itempreferencepckey,deleted,shareqty,remarks,billpckey,imeno,kactive,pickedup,ktaken,kotdisplay,msrcardpckey,refkotno,measure,terminalpckey,forstock,cckey) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_numbermaster=insert into numbermaster (nopckey,pospckey,kotno,billno,ncbillno,active,nckotno,cbillno,ckotno) values (?,?,?,?,?,?,?,?,?)  
sql.insert_purchaseline=insert into purchaseline (plinepckey,pheadpckey,ingredientpckey,qty,freeqty,rate) values (?,?,?,?,?,?)  
sql.insert_tabkots=insert into tabkots (kotlinepckey,kotnumber,tablepckey,kotdatetime,itempckey,rate,qty,measurepckey,openitemname,itempreferencepckey,deleted,shareqty,remarks,imeno,processed) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_purchasehead=insert into purchasehead (purchaseheadpckey,purchasedate,purchasevoucherno,supplierpckey,supplierbillno,remarks,usercode) values (?,?,?,?,?,?,?)  
sql.insert_msrcards=insert into msrcards (pckey,cardno,linkedtotable) values (?,?,?)  
sql.insert_printermaster=insert into printermaster (printerpckey,printername,papersizeinches,active) values (?,?,?,?)  
sql.insert_kotshold=insert into kotshold (kotlinepckey,kotnumber,tablepckey,kotdatetime,itempckey,rate,qty,measurepckey,openitemname,itempreferencepckey,deleted,shareqty,remarks,billpckey,imeno,kactive,pickedup,ktaken,kotdisplay,msrcardpckey,refkotno,measure,forstock) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_settlementmaster=insert into settlementmaster (settlementpckey,settlementname,active,selected,amount,getdetails,getdebtor,tallygroup,tallyhead,tallyupdated,hmslinked,hmstccode,checkinpckey,debtorpckey,shortname,cckey,lupd,showrefund) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_homecustomer=insert into homecustomer (customerpckey,phoneno,name,address,pincode,landmark,active,cckey) values (?,?,?,?,?,?,?,?)  
sql.insert_terminalline=insert into terminalline (pckey,terminalpckey,allowedposareapckey,active,cckey,lupd) values (?,?,?,?,?,?)  
sql.insert_taxmasterstores=insert into taxmasterstores (taxpckey,taxdescription,rate,applyorder,slab,nettofdiscount,aspercentage,applicablebasicdcamountonly,applicablebasicplusothertaxes,tallyposted,tallyhead,shortname,taxoth,active) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_tablegroupmaster=insert into tablegroupmaster (tablegrouppckey,groupname,active,cckey,lupd) values (?,?,?,?,?)  
sql.insert_itemgroupmasterold=insert into itemgroupmasterold (itemgrouppckey,groupname,itemcategorypckey,kitchenpckey,baritem,cocktail,combo,active) values (?,?,?,?,?,?,?,?)  
sql.insert_tablemaster=insert into tablemaster (tablepckey,tableno,posareapckey,currentwaiterpckey,currentcaptainpckkey,occupied,hdelivery,active,currentlyoccupiedpax,directbill,printkot,displayrow,displaycol,tablegrouppckey,currentcaptainname,currentwaitername,description,nwidth,bill,foodready,hdpckey,pickupbycustomer,ncbill,disbill,discountrate,personname,authorizedby,departmentname,unsettled,settlepckey,billamount,billpckey,inhold,firstkottime,billno,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_billlinemerge=insert into billlinemerge (mergelinepckey,billlinepckey,billpckey,qty,rate,settlepckey,upd,del) values (?,?,?,?,?,?,?,?)  
sql.insert_ckots=insert into ckots (kotlinepckey,kotnumber,tablepckey,kotdatetime,itempckey,rate,qty,measurepckey,openitemname,itempreferencepckey,deleted,shareqty,remarks,billpckey) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_purchasetaxrtnline=insert into purchasetaxrtnline (pckey,purchaselinepckey,taxpckey,rate,amount) values (?,?,?,?,?)  
sql.insert_menu=insert into menu (mainmenu,actn,caption,description,submenuofaction,controlid,admin) values (?,?,?,?,?,?,?)  
sql.insert_bomhead=insert into bomhead (bompckey,salableitempckey,baseqty,uom,salableunits,salableuompckey,active) values (?,?,?,?,?,?,?)  
sql.insert_controltable=insert into controltable (pckey,companyname,address,phone,active,lastcloseddate) values (?,?,?,?,?,?)  
sql.insert_platetypes=insert into platetypes (pckey,platetype,weightingrams,active) values (?,?,?,?)  
sql.insert_itemcategorymasterold=insert into itemcategorymasterold (categorypckey,categoryname,rawmaterial,breakbill,active) values (?,?,?,?,?)  
sql.insert_indentissuehead=insert into indentissuehead (indentheadpckey,indentno,indentdate,indentdepartment,remarks,usercode) values (?,?,?,?,?,?)  
sql.insert_billhead=insert into billhead (billpckey,billno,billdate,serverdate,posareapckey,tablepckey,waiterpckey,pax,captainpckey,billbasicamount,billtaxes,billdiscount,billroundoff,billnetamount,settlementpckey,cancelled,reasonforcancellation,hmscheckinpckey,debtorpckey,remarks,reprintcount,nc,ncamount,hdpckey,sessionpckey,ldiscount,dbpckey,terminalpckey,deliverysettle,reprinttime,parcelover,rp,tosms,pickupbycustomer,updated,checkinpckey) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_poscontrol=insert into poscontrol (pckey,posname,posaddress,phone,rateeffectivefrom,active,lastcloseddate,lmd,lh,emaillinked,smslink,posaddress2,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_cbilllineitems=insert into cbilllineitems (billlinepckey,billpckey,kotnumber,kottime,itempckey,qty,rate,openitemname,measurepckey,reamarks) values (?,?,?,?,?,?,?,?,?,?)  
sql.insert_printerfonts=insert into printerfonts (fontlinepckey,fontpckey,printerpckey,controlchar1,controlchar2,controlchar3,controlchar4,active) values (?,?,?,?,?,?,?,?)  
sql.insert_stock=insert into stock (pckey,itempckey,trndate,trntype,quantity,rate) values (?,?,?,?,?,?)  
sql.insert_devicemaster=insert into devicemaster (deviceid,imeno,waiterpckey) values (?,?,?)  
sql.insert_kotprintermaster=insert into kotprintermaster (kotprinterpckey,posareapckey,terminalpckey,allkitchens,kitchenpckey,kotprintername,noofcopies,alsoprinto_printername,noofcopies_2ndprinter,active,printertype,printermode,printerpckey) values (?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_taxmaster=insert into taxmaster (taxpckey,taxdescription,rate,applyorder,slab,nettofdiscount,aspercentage,applicablebasicdcamountonly,applicablebasicplusothertaxes,tallyposted,tallyhead,shortname,active,posareapckey,itemcategorypckey,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)  
sql.insert_ingredientmaster=insert into ingredientmaster (ingredientspckey,ingredientsgrouppckey,ingredientname,uompckey,issueuompckey,moq,active,uom2issueuomconversoinfactor,vernacularname) values (?,?,?,?,?,?,?,?,?)  
sql.insert_purchasetaxline=insert into purchasetaxline (ptaxlinepckey,pheadpckey,plinepckey,taxpckey,rate,amount) values (?,?,?,?,?,?)  
sql.insert_usermast=insert into usermast (usercode,username,password,rights,active,cckey,lupd) values (?,?,?,?,?,?,?)  
sql.insert_sharebymaster=insert into sharebymaster (sharedbypckey,shareby,active) values (?,?,?)  
sql.insert_settlementlinedetails=insert into settlementlinedetails (settlementremarkspckey,settlelinepckey,instrumentno,instrumentdate,instrumentbank,instumentamount,lineremarks) values (?,?,?,?,?,?,?)  
sql.insert_kitchenmaster=insert into kitchenmaster (kitchenpckey,kitchenname,breakkot,breakserial,active,tvdisplay,cckey,luod) values (?,?,?,?,?,?,?,?)  
sql.insert_itemcategorymaster=insert into itemcategorymaster (categorypckey,categoryname,displayname,catetype,breakbill,active,cusdisplayorder,maintainstock,cckey,lupd) values (?,?,?,?,?,?,?,?,?,?)  
sql.insert_settlehead=insert into settlehead (settleheadpckey,settlementtype,settlementdate,settlementamount,remarks,serverdate,terminalpckey) values (?,?,?,?,?,?,?)  






##


sql.update_arap=update arap set arappckey = ?,arapdate = ?,sourcepcksy = ?,sourcedoctype = ?,refpckey = ?,refdoctype = ?,debtorpckey = ?,amount = ?,drcr = ?,openingrecord = ?,openingrefdetails=? where arappckey = ?  
sql.update_backuphead=update backuphead set backuppckey = ?,backuppath=? where backuppckey = ?  
sql.update_billlinetaxes=update billlinetaxes set billlinepckey = ?,billpckey = ?,taxpckey = ?,amount=? where billlinepckey = ?  
sql.update_bomline=update bomline set bomlinepckey = ?,bomheadpckey = ?,ingredientpckey = ?,qty = ?,uom=? where bomlinepckey = ?  
sql.update_bomhead=update bomhead set bompckey = ?,salableitempckey = ?,baseqty = ?,uom = ?,salableunits = ?,salableuompckey = ?,active=? where bompckey = ?  
sql.update_cbillhead=update cbillhead set billpckey = ?,billno = ?,billdate = ?,serverdate = ?,posareapckey = ?,tablepckey = ?,waiterpckey = ?,pax = ?,captainpckey = ?,billbasicamount = ?,billtaxes = ?,billdiscount = ?,billroundoff = ?,billnetamount = ?,settlementpckey = ?,cancelled = ?,reasonforcancellation = ?,hmscheckinpckey = ?,debtorpckey = ?,remarks = ?,reprintcount = ?,nc = ?,ncamount = ?,hdpckey = ?,sessionpckey = ?,ldiscount = ?,dbpckey = ?,terminalpckey = ?,deliverysettle=? where billpckey = ?  
sql.update_billlineitems=update billlineitems set billlinepckey = ?,billpckey = ?,kotnumber = ?,kottime = ?,itempckey = ?,qty = ?,rate = ?,openitemname = ?,measurepckey = ?,reamarks = ?,imeno = ?,pactive=? where billlinepckey = ?  
sql.update_billhead=update billhead set billpckey = ?,billno = ?,billdate = ?,serverdate = ?,posareapckey = ?,tablepckey = ?,waiterpckey = ?,pax = ?,captainpckey = ?,billbasicamount = ?,billtaxes = ?,billdiscount = ?,billroundoff = ?,billnetamount = ?,settlementpckey = ?,cancelled = ?,reasonforcancellation = ?,hmscheckinpckey = ?,debtorpckey = ?,remarks = ?,reprintcount = ?,nc = ?,ncamount = ?,hdpckey = ?,sessionpckey = ?,ldiscount = ?,dbpckey = ?,terminalpckey = ?,deliverysettle = ?,reprinttime = ?,parcelover = ?,rp = ?,tosms = ?,pickupbycustomer = ?,updated = ?,checkinpckey=? where billpckey = ?  
sql.update_captainmaster=update captainmaster set captainpckey = ?,captainname = ?,captainshortname = ?,posareapckey = ?,active = ?,pw = ?,defaultcaptain = ?,cckey = ?,lupd=? where captainpckey = ?  
sql.update_billlinemerge=update billlinemerge set mergelinepckey = ?,billlinepckey = ?,billpckey = ?,qty = ?,rate = ?,settlepckey = ?,upd = ?,del=? where mergelinepckey = ?  
sql.update_issueline=update issueline set issuepckey = ?,issuetype = ?,issuedatetime = ?,indentissuelinepckey = ?,issuedqty = ?,rtnqty=? where issuepckey = ?  
sql.update_complementdiscountncline=update complementdiscountncline set linepckey = ?,cdncpckey = ?,linediscription = ?,active=? where linepckey = ?  
sql.update_cbilllinetaxes=update cbilllinetaxes set billlinepckey = ?,billpckey = ?,taxpckey = ?,amount=? where billlinepckey = ?  
sql.update_cbilllineitems=update cbilllineitems set billlinepckey = ?,billpckey = ?,kotnumber = ?,kottime = ?,itempckey = ?,qty = ?,rate = ?,openitemname = ?,measurepckey = ?,reamarks=? where billlinepckey = ?  
sql.update_deletedkots=update deletedkots set pckey = ?,kotno = ?,kotdatetime = ?,deleteddatetime = ?,tableno = ?,waitername = ?,itempckey = ?,qty = ?,reasonfordeletion = ?,sessioncode = ?,captainname = ?,posareapckey = ?,stnono = ?,pax = ?,nc = ?,cckey=? where pckey = ?  
sql.update_itemcategorymasterold=update itemcategorymasterold set categorypckey = ?,categoryname = ?,rawmaterial = ?,breakbill = ?,active=? where categorypckey = ?  
sql.update_kots=update kots set kotlinepckey = ?,kotnumber = ?,tablepckey = ?,kotdatetime = ?,itempckey = ?,rate = ?,qty = ?,measurepckey = ?,openitemname = ?,itempreferencepckey = ?,deleted = ?,shareqty = ?,remarks = ?,billpckey = ?,imeno = ?,kactive = ?,pickedup = ?,ktaken = ?,kotdisplay = ?,msrcardpckey = ?,refkotno = ?,measure = ?,terminalpckey = ?,forstock = ?,cckey=? where kotlinepckey = ?  
sql.update_indentauthorize=update indentauthorize set pckey = ?,authdatetime = ?,usercode = ?,indentissuelinepckey = ?,authqty = ?,remarks=? where pckey = ?  
sql.update_indentissueline=update indentissueline set indentissuelinepckey = ?,indentheadpckey = ?,ingredientspckey = ?,indentqty = ?,remarks = ?,autorizedby = ?,authorizeddatetime = ?,authorizedqty = ?,authorizatoinremarks = ?,issuedqty = ?,issuedby = ?,issuedon = ?,issueremarks = ?,receivedqty = ?,receivedon=? where indentissuelinepckey = ?  
sql.update_platetypes=update platetypes set pckey = ?,platetype = ?,weightingrams = ?,active=? where pckey = ?  
sql.update_itemgroupmasterold=update itemgroupmasterold set itemgrouppckey = ?,groupname = ?,itemcategorypckey = ?,kitchenpckey = ?,baritem = ?,cocktail = ?,combo = ?,active=? where itemgrouppckey = ?  
sql.update_tmpstock=update tmpstock set pckey = ?,itempckey = ?,groupname = ?,itemname = ?,opening = ?,openingrate = ?,openingvalue = ?,purchase = ?,purchaserate = ?,purchasevalue = ?,issue = ?,issuerate = ?,issuevalue = ?,wastage = ?,wastagerate = ?,wastagevalue = ?,closingstock = ?,closingstockrate = ?,closingstockvalue=? where pckey = ?  
sql.update_msrcards=update msrcards set pckey = ?,cardno = ?,linkedtotable=? where pckey = ?  
sql.update_settlementlinedetails=update settlementlinedetails set settlementremarkspckey = ?,settlelinepckey = ?,instrumentno = ?,instrumentdate = ?,instrumentbank = ?,instumentamount = ?,lineremarks=? where settlementremarkspckey = ?  
sql.update_fontmaster=update fontmaster set fontpckey = ?,fontname = ?,active=? where fontpckey = ?  
sql.update_indentissuehead=update indentissuehead set indentheadpckey = ?,indentno = ?,indentdate = ?,indentdepartment = ?,remarks = ?,usercode=? where indentheadpckey = ?  
sql.update_tablemaster=update tablemaster set tablepckey = ?,tableno = ?,posareapckey = ?,currentwaiterpckey = ?,currentcaptainpckkey = ?,occupied = ?,hdelivery = ?,active = ?,currentlyoccupiedpax = ?,directbill = ?,printkot = ?,displayrow = ?,displaycol = ?,tablegrouppckey = ?,currentcaptainname = ?,currentwaitername = ?,description = ?,nwidth = ?,bill = ?,foodready = ?,hdpckey = ?,pickupbycustomer = ?,ncbill = ?,disbill = ?,discountrate = ?,personname = ?,authorizedby = ?,departmentname = ?,unsettled = ?,settlepckey = ?,billamount = ?,billpckey = ?,inhold = ?,firstkottime = ?,billno = ?,cckey = ?,lupd=? where tablepckey = ?  
sql.update_ckots=update ckots set kotlinepckey = ?,kotnumber = ?,tablepckey = ?,kotdatetime = ?,itempckey = ?,rate = ?,qty = ?,measurepckey = ?,openitemname = ?,itempreferencepckey = ?,deleted = ?,shareqty = ?,remarks = ?,billpckey=? where kotlinepckey = ?  
sql.update_settlehead=update settlehead set settleheadpckey = ?,settlementtype = ?,settlementdate = ?,settlementamount = ?,remarks = ?,serverdate = ?,terminalpckey=? where settleheadpckey = ?  
sql.update_numbermasterstores=update numbermasterstores set pckey = ?,doctype = ?,nextnumber=? where pckey = ?  
sql.update_posarea=update posarea set posareapckey = ?,posareaname = ?,localstno = ?,cstno = ?,directbill = ?,printkot = ?,headernotes = ?,footernotes = ?,billprefix = ?,billsuffix = ?,dailystartwithbillno1 = ?,promptkotprint = ?,promptbillprint = ?,noofkotcopies = ?,noofbillcopies = ?,homedelivery = ?,hmslinked = ?,hmstccode = ?,tallylinked = ?,tallysaleshead = ?,netratefactor = ?,active = ?,getcaptain = ?,gettable = ?,getwaiter = ?,getkotnumber = ?,getpax = ?,getgroup = ?,getnumericcode = ?,getalphacode = ?,currentsessionpckey = ?,barpos = ?,smslink = ?,defaultwaiterpckey = ?,defaultcaptainpckey = ?,defaultsettlementpckey = ?,touch = ?,lh = ?,promptforsettlement = ?,pendingsettlementcode = ?,checkstock = ?,hmstc = ?,printkotafterbill = ?,defailttablepckey = ?,getphone = ?,openitemgroup = ?,cckey = ?,lupd=? where posareapckey = ?  
sql.update_sessionmaster=update sessionmaster set sessionpckey = ?,sessionname = ?,fromtime = ?,totime = ?,posareapckey = ?,active = ?,nextsession = ?,cckey = ?,lupd=? where sessionpckey = ?  
sql.update_purchasertn=update purchasertn set pckey = ?,rtndate = ?,purchaselinepckey = ?,qty = ?,remarks = ?,usercode=? where pckey = ?  
sql.update_settleline=update settleline set settlelinepckey = ?,settleheadpckey = ?,settlemasterpckey = ?,settlementamount = ?,remarks=? where settlelinepckey = ?  
sql.update_itemrates=update itemrates set ratepckey = ?,itempckey = ?,posareapckey = ?,rate = ?,issueuom = ?,issueconversionmeasure = ?,rateeffectivefrom = ?,active = ?,cckey = ?,lupd=? where ratepckey = ?  
sql.update_kotshold=update kotshold set kotlinepckey = ?,kotnumber = ?,tablepckey = ?,kotdatetime = ?,itempckey = ?,rate = ?,qty = ?,measurepckey = ?,openitemname = ?,itempreferencepckey = ?,deleted = ?,shareqty = ?,remarks = ?,billpckey = ?,imeno = ?,kactive = ?,pickedup = ?,ktaken = ?,kotdisplay = ?,msrcardpckey = ?,refkotno = ?,measure = ?,forstock=? where kotlinepckey = ?  
sql.update_tabkots=update tabkots set kotlinepckey = ?,kotnumber = ?,tablepckey = ?,kotdatetime = ?,itempckey = ?,rate = ?,qty = ?,measurepckey = ?,openitemname = ?,itempreferencepckey = ?,deleted = ?,shareqty = ?,remarks = ?,imeno = ?,processed=? where kotlinepckey = ?  
sql.update_purchasehead=update purchasehead set purchaseheadpckey = ?,purchasedate = ?,purchasevoucherno = ?,supplierpckey = ?,supplierbillno = ?,remarks = ?,usercode=? where purchaseheadpckey = ?  
sql.update_ingredientmaster=update ingredientmaster set ingredientspckey = ?,ingredientsgrouppckey = ?,ingredientname = ?,uompckey = ?,issueuompckey = ?,moq = ?,active = ?,uom2issueuomconversoinfactor = ?,vernacularname=? where ingredientspckey = ?  
sql.update_combooptions=update combooptions set combopckey = ?,itempckey = ?,optionno = ?,options = ?,active=? where combopckey = ?  
sql.update_itemcategorymaster=update itemcategorymaster set categorypckey = ?,categoryname = ?,displayname = ?,catetype = ?,breakbill = ?,active = ?,cusdisplayorder = ?,maintainstock = ?,cckey = ?,lupd=? where categorypckey = ?  
sql.update_devicemaster=update devicemaster set deviceid = ?,imeno = ?,waiterpckey=? where deviceid = ?  
sql.update_settlementmaster=update settlementmaster set settlementpckey = ?,settlementname = ?,active = ?,selected = ?,amount = ?,getdetails = ?,getdebtor = ?,tallygroup = ?,tallyhead = ?,tallyupdated = ?,hmslinked = ?,hmstccode = ?,checkinpckey = ?,debtorpckey = ?,shortname = ?,cckey = ?,lupd = ?,showrefund=? where settlementpckey = ?  
sql.update_poscontrol=update poscontrol set pckey = ?,posname = ?,posaddress = ?,phone = ?,rateeffectivefrom = ?,active = ?,lastcloseddate = ?,lmd = ?,lh = ?,emaillinked = ?,smslink = ?,posaddress2 = ?,cckey = ?,lupd=? where pckey = ?  
sql.update_printerfonts=update printerfonts set fontlinepckey = ?,fontpckey = ?,printerpckey = ?,controlchar1 = ?,controlchar2 = ?,controlchar3 = ?,controlchar4 = ?,active=? where fontlinepckey = ?  
sql.update_taxstructuremaster=update taxstructuremaster set taxstructurepckey = ?,taxpckey = ?,applyorder = ?,fromslabamount = ?,toslabamount = ?,slabcharge = ?,active=? where taxstructurepckey = ?  
sql.update_taxmaster=update taxmaster set taxpckey = ?,taxdescription = ?,rate = ?,applyorder = ?,slab = ?,nettofdiscount = ?,aspercentage = ?,applicablebasicdcamountonly = ?,applicablebasicplusothertaxes = ?,tallyposted = ?,tallyhead = ?,shortname = ?,active = ?,posareapckey = ?,itemcategorypckey = ?,cckey = ?,lupd=? where taxpckey = ?  
sql.update_ingredientgroups=update ingredientgroups set ingredientsgrouppckey = ?,groupname = ?,expense = ?,active=? where ingredientsgrouppckey = ?  
sql.update_sharebymaster=update sharebymaster set sharedbypckey = ?,shareby = ?,active=? where sharedbypckey = ?  
sql.update_homecustomer=update homecustomer set customerpckey = ?,phoneno = ?,name = ?,address = ?,pincode = ?,landmark = ?,active = ?,cckey=? where customerpckey = ?  
sql.update_complementdiscountnchead=update complementdiscountnchead set cdncpckey = ?,description = ?,active=? where cdncpckey = ?  
sql.update_purchaseline=update purchaseline set plinepckey = ?,pheadpckey = ?,ingredientpckey = ?,qty = ?,freeqty = ?,rate=? where plinepckey = ?  
sql.update_taxmasterstores=update taxmasterstores set taxpckey = ?,taxdescription = ?,rate = ?,applyorder = ?,slab = ?,nettofdiscount = ?,aspercentage = ?,applicablebasicdcamountonly = ?,applicablebasicplusothertaxes = ?,tallyposted = ?,tallyhead = ?,shortname = ?,taxoth = ?,active=? where taxpckey = ?  
sql.update_tabmaster=update tabmaster set tabid = ?,tabkey = ?,tabimeno = ?,active=? where tabid = ?  
sql.update_controltable=update controltable set pckey = ?,companyname = ?,address = ?,phone = ?,active = ?,lastcloseddate=? where pckey = ?  
sql.update_kotprintermaster=update kotprintermaster set kotprinterpckey = ?,posareapckey = ?,terminalpckey = ?,allkitchens = ?,kitchenpckey = ?,kotprintername = ?,noofcopies = ?,alsoprinto_printername = ?,noofcopies_2ndprinter = ?,active = ?,printertype = ?,printermode = ?,printerpckey=? where kotprinterpckey = ?  
sql.update_tablegroupmaster=update tablegroupmaster set tablegrouppckey = ?,groupname = ?,active = ?,cckey = ?,lupd=? where tablegrouppckey = ?  
sql.update_debtormaster=update debtormaster set debtormaster = ?,debtorname = ?,contactphoneno = ?,address = ?,active=? where debtormaster = ?  
sql.update_terminalline=update terminalline set pckey = ?,terminalpckey = ?,allowedposareapckey = ?,active = ?,cckey = ?,lupd=? where pckey = ?  
sql.update_devicelocation=update devicelocation set pckey = ?,waiterpckey = ?,lat = ?,lon = ?,dttime = ?,billpckey=? where pckey = ?  
sql.update_suppliermaster=update suppliermaster set supplierpckey = ?,suppliername = ?,supplieraddress = ?,cstno = ?,vat = ?,phone = ?,contactperson = ?,active=? where supplierpckey = ?  
sql.update_numbermaster=update numbermaster set nopckey = ?,pospckey = ?,kotno = ?,billno = ?,ncbillno = ?,active = ?,nckotno = ?,cbillno = ?,ckotno=? where nopckey = ?  
sql.update_kitchenmaster=update kitchenmaster set kitchenpckey = ?,kitchenname = ?,breakkot = ?,breakserial = ?,active = ?,tvdisplay = ?,cckey = ?,luod=? where kitchenpckey = ?  
sql.update_purchasetaxrtnline=update purchasetaxrtnline set pckey = ?,purchaselinepckey = ?,taxpckey = ?,rate = ?,amount=? where pckey = ?  
sql.update_waitermaster=update waitermaster set waiterpckey = ?,waitername = ?,posareapckey = ?,waitershortname = ?,allinallposarea = ?,active = ?,mobileno = ?,lon = ?,lat = ?,defaultwaiter = ?,cckey = ?,lupd=? where waiterpckey = ?  
sql.update_uommaster=update uommaster set uompckey = ?,uomdescription = ?,posareapckey = ?,active = ?,cckey = ?,lupd=? where uompckey = ?  
sql.update_terminalhead=update terminalhead set terminalpckey = ?,terminalname = ?,touchpos = ?,location = ?,active = ?,rkotallowed = ?,cckey = ?,lupd=? where terminalpckey = ?  
sql.update_menu=update menu set mainmenu = ?,actn = ?,caption = ?,description = ?,submenuofaction = ?,controlid = ?,admin=? where mainmenu = ?  
sql.update_usermast=update usermast set usercode = ?,username = ?,password = ?,rights = ?,active = ?,cckey = ?,lupd=? where usercode = ?  
sql.update_itemmaster=update itemmaster set itempckey = ?,itemcode = ?,grouppckey = ?,itemname = ?,alphacode = ?,active = ?,uompckey = ?,defaultissueuom = ?,menudisplayorder = ?,discountallowed = ?,rate1 = ?,rate2 = ?,stockin = ?,issued = ?,vendorrate = ?,cckey = ?,lupd=? where itempckey = ?  
sql.update_stock=update stock set pckey = ?,itempckey = ?,trndate = ?,trntype = ?,quantity = ?,rate=? where pckey = ?  
sql.update_purchasetaxline=update purchasetaxline set ptaxlinepckey = ?,pheadpckey = ?,plinepckey = ?,taxpckey = ?,rate = ?,amount=? where ptaxlinepckey = ?  
sql.update_printermaster=update printermaster set printerpckey = ?,printername = ?,papersizeinches = ?,active=? where printerpckey = ?  
sql.update_itemgroupmaster=update itemgroupmaster set itemgrouppckey = ?,groupname = ?,itemcategorypckey = ?,kitchenpckey = ?,vegnv = ?,baritem = ?,outsourced = ?,combo = ?,taxable = ?,active = ?,cckey = ?,lupd=? where itemgrouppckey = ?  
sql.update_itempreference=update itempreference set itempreferencepckey = ?,description = ?,itempckey = ?,active=? where itempreferencepckey = ?
 

elitevenkat

Active Member
Licensed User
Longtime User
OK I have not used transaction with RDC, in fact I don't know how to start a transaction in RDC. Can someone guide me.
I am using the executebatch for both inserts and update.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
JRDC has transactions already integrated.

What Erel means is for this code in particular:

B4X:
            For i=0 To lrst.Size-1
              '  Log( "update " & m.GetKeyAt(0) & "set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) ) 
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) ) 
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webmodify=0  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) ) 
                lblDone.Text=i+1
                'Log( "Key " & lrst.Get(i))                 
            Next

You are not using transactions. it should be something like this:

B4X:
sqlDB.beginTransaction
try
            For i=0 To lrst.Size-1
              '  Log( "update " & m.GetKeyAt(0) & "set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) ) 
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webupdated=1  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) ) 
                sqlDb.ExecNonQuery("update " & m.GetKeyAt(0) & " set webmodify=0  where " & m.GetKeyAt(1) & "=" & lrst.Get(i) ) 
                lblDone.Text=i+1
                'Log( "Key " & lrst.Get(i))                 
            Next
SqlDB.TransactionSuccessful
Catch
SqlDB.RollBack
End Try
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
oh and you are using B4J 5.00 and that is so... April 2017!

For better code use 5.51 and Wait for Async calls to JRDC
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
But you are not using batches in the code you posted above!?
B4X:
If blnGotrecs Then Dim tParm AsString =""For i=0To cParm.Length-1
 tParm=tParm & cParm(i) & ","
 NextLog(tParm)Dim m AsMap
 m.Initialize
 m.Put(rsTbl.GetString2(1),"WEB_INSERT")
 m.Put(rsTbl.GetString2(2),lKeys)
 
 rm.ExecuteBatch(lstCmd, m)EndIfLoop
Yes Don you are correct, I have used in RDC call only and not in dbutility.
 
Upvote 0
Top