Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
Data Insertion in Master Detail Tables. |
Wed, Feb 17 2010 4:48 AM | Permanent Link |
Eeman Khan | Hi,
the codes works fine, but i want to know am i doing the insertion right way .. please advice code given below // Values Insertion in Master Table. // ----------------------------------------------------------------------------- if not tR.Active then tR.Active := True; DM.DB.StartTransaction; Try with tR do begin if Locate('SerialNo', eSerialNo.Text, []) then Edit else begin Append; FieldByName('TimeStamp').AsDateTime := Now; end; FieldByName('SerialNo').AsInteger := StrToInt(eSerialNo.Text); FieldByName('Date').AsDateTime := eDate.Date; FieldByName('ClassName').Text := eClassName.Text; FIeldByName('RegistrationNo').Text := eRegistrationNO.Text; FieldBYName('RollNo').AsInteger := StrToInt(eRollNo.Text); FieldByName('Remarks').AsInteger := eStatus.ItemIndex; FieldByName('Term').AsInteger := eTerm.ItemIndex; FieldByName('TermName').Text := eTerm.Text; FieldByName('PromotedInClass').AsInteger := ePromotedInClass.ItemIndex; FieldByName('ObtainedMarks').AsInteger := tvG.DataController.Summary.FooterSummaryValues[0]; FieldByName('MaximumMarks').AsInteger := tvG.DataController.Summary.FooterSummaryValues[1]; FieldByName('Average').AsInteger := (tvG.DataController.Summary.FooterSummaryValues[0] * 100 / tvG.DataController.Summary.FooterSummaryValues[1]); Post; end; DM.DB.commit(True); except DM.DB.RollBack; end; tR.Active := False; // ----------------------------------------------------------------------------- //Values Insertion in Detail Table. // ------------------------------------------------------------------------------- for I := 0 to tvG.DataController.RowCount - 1 do begin v1 := tvG.DataController.Values [I, cObtainedMarks]; v2 := tvG.DataController.Values [I, cMaximumMarks]; if v2 = Null then goto SkipLine; begin if not tRD.Active then tRD.Active := True; DM.DB.StartTransaction; Try if tRD.Locate('SerialNo;Order', VarArrayOf([eSerialNo.Text, IntToStr(I)]), []) then tRD.Edit else begin tRD.Append; tRD.FieldByName('TimeStamp').AsDateTime := Now; end; tRD.FieldByName('Order').AsInteger := I; tRD.FieldByName('SerialNo').AsInteger := StrToInt(eSerialNo.Text); tRD.FieldByName('SubjectID').AsInteger := tvG.DataController.Values [I, cSubjectID]; tRD.FieldByName('SubjectName').Text := tvG.DataController.Values [I, cSubjectName]; if tvG.DataController.Values [I, cObtainedMarks] <> Null then tRD.FieldByName('ObtainedMarks').AsInteger := tvG.DataController.Values [I, cObtainedMarks]; if tvG.DataController.Values [I, cMaximumMarks] <> Null then tRD.FieldByName('MaximumMarks').AsInteger := tvG.DataController.Values [I, cMaximumMarks]; if tvG.DataController.Values [I, cRemarks] <> Null then tRD.FieldByName('Remarks').Text := FormatFloat('0.00', tvG.DataController.Values [I, cRemarks]); tRD.Post; DM.DB.commit(True); except DM.DB.RollBack; end; tRD.Active := False; SkipLine: end; end; // ----------------------------------------------------------------------------- |
Wed, Feb 17 2010 12:23 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eeman,
<< the codes works fine, but i want to know am i doing the insertion right way .. please advice code given below >> You should put the StartTransaction..Commit/Rollback block around all of the edits/inserts, and not execute separate transactions for each. That will ensure that the group of master and detail edits/inserts is posted as an atomic unit of work. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Feb 17 2010 10:38 PM | Permanent Link |
Eeman Khan | can you convert my code to your said solution,
at first i didnot encrupt my database with password, now i encrypted the tables and the speed of edits/inserts slow 20%, any suggestion in this regards <<You should put the StartTransaction..Commit/Rollback block around all of the edits/inserts, and not execute separate transactions for each. That will ensure that the group of master and detail edits/inserts is posted as an atomic unit of work.>> |
Thu, Feb 18 2010 11:55 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eeman,
<< can you convert my code to your said solution, >> Here it the psuedo-code: StartTransaction; try Insert/Update Master; Loop and Insert/Update Details Commit; except Rollback; raise; end; << at first i didnot encrupt my database with password, now i encrypted the tables and the speed of edits/inserts slow 20%, any suggestion >> That's just the overhead of the encryption. It's strong crypto, so there's not much you can do about it. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |