TELOS KIM 0 Posted January 17, 2022 (edited) Procedure TfmMaster.btn Click OK (Sender: TObject); var InStr : string; begin for var i := 0 to Memo2.Lines.Count -1 begin InStr := copy(Memo2.Lines.Strings ,1,18) ; bQry.Close; bQry.CommandText := ' UPDATE "acCountsB" sET state = 1' +#10+' where substring(barcoding,1,18) = '''+ InStr +''' ' +#10+' and state is null ; ' +#10+'Select a4_ box quantity ,' +#10+' Sum(state) As system,' +#10+' A8_Invoice number ,A3_Delivery tracking ,A3_Unit price ,A7_Serial number,A0 _Vendor coding,' +#10+' A1_Seller Name, A8_Part Number, A9_Product Name, A4_Standard, A1_ Eco, A2_Quantity,' +#10+' A1_Acquired Customer Name,ItemName' +#10+' from "acCounts" a' +#10+' Right Join "acCountsB" b on ( Left(a.A8_invoice number, +#10+' and Substring(b. Invoice number,1,18) in' +#10+' (Select Left(Invoice Number,18) from "'+DBTO+'acCountsB" b' +#10+' Right Join "acCounts" a on (Left(a.A8_Invoice Number,18) = Left(b.Invoice Number,18) )' +#10+' where substring(barcoding,1,18) = '''+ InStr + ''' ' +#10+' and status is not null )' +#10+' and a.A8_Buy Male<>''Cancel''' +#10+'Group By 1' +#10+' total = a4_ box quantity' ; bQry.open try; bQry.open; except Get_ErrorEvent_Post( DM.Qry , StringReplace(bQry.CommandText,DBTO,'',[rfReplaceAll]) ); End; sleep (100); if bQry.RecordCount > 0 then begin InStr := copy( bQry.FieldByName('A8_InvoiceNumber').AsString,1 ,18) ; aQry.CommandText := 'update acCountsB set state = Null '#10 +' where substring(invoice number,1,18) = '''+ InStr +''' ; '#10 +' Update 'Account' a.A8_Shipping Status = '+cBaeSongStar+' '#10 +' ,a.A5_Delivery Departure = '''+jesaStartEnd+''' '#10 +' ,a .A3_tracking = a.A3_tracking+'''+jesatEndComCode+'''+#10 '#10 +' ,a.A5_processor = '''+tusername+'/'+tid +''' '#10 +' left outer join "acCounts" b on (a.A8_invoice number=b.A8_invoice number) '#10 +' where substring(A8_invoice number,1,18) = '''+ InStr +' '' '#10 +' and A8_Shipping Status = '+cJeSaEnd+' '#10 +' and A8_Purchase change <>''Cancel'' ; '; try aQry.Execute ; exception Get_ErrorEvent_Post( DM.Qry , StringReplace(aQry.CommandText,DBTO,'',[rfReplaceAll]) ); End; end; End; End; Edited January 18, 2022 by TELOS KIM Share this post Link to post
Dalija Prasnikar 1396 Posted January 18, 2022 Can you please translate your logic to English. It is extremely hard to follow what you are doing. Especially, since TTask.Run code is basically empty and it requires way more context. Share this post Link to post
TELOS KIM 0 Posted January 19, 2022 (edited) 15 hours ago, Dalija Prasnikar said: 당신의 논리를 영어로 번역해 주시겠습니까? 당신이 하는 일을 따라가는 것은 매우 어렵습니다. 특히 TTask.Run 코드는 기본적으로 비어 있기 때문에 더 많은 컨텍스트가 필요합니다. Thank you for always. Thanks for answering my question I am using Android phone Datasnap environment. In the Android environment, the query processing time is a little slow, so it bounces off. Please provide an Android query example so that you can safely execute the query. Edited January 19, 2022 by TELOS KIM Share this post Link to post
TiGü 21 Posted January 19, 2022 I assume aQry and bQry are of the Datasnap.DBClient.TClientDataSet type? Please remove the Sleep(100) call and put all the logic after if bQry.RecordCount > 0 then ... in the AfterOpen event handler from bQry (see https://docwiki.embarcadero.com/Libraries/Sydney/en/Data.DB.TDataSet.AfterOpen). Share this post Link to post