Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
Copy records between tables |
Thu, Nov 19 2020 10:12 AM | Permanent Link |
Peter van Mierlo EVENTSOFT | Hi
For a moment I don't see why one code works and the other doesn't. I want to copy records from one table to another.where the structure is identical This code DOES works: procedure WristbandPrintScan; var iCount: LongInt; sName: string; begin if NOT dmMain.Scan.Active then dmMain.Scan.Active := TRUE; dmMain.WristbandPrint.First; with dmMain.WristbandPrint do begin while NOT EOF do begin dmMain.Scan.Insert; for iCount := 0 to dmMain.Scan.FieldCount - 1 do begin sName := dmMain.Scan.Fields[iCount].FieldName; if (dmMain.WristbandPrint.FindField(sName) <> nil) and (sName <> 'WristbandPrintID') then dmMain.Scan.FieldByName(sName).Assign(dmMain.WristbandPrint.FieldByName(sName)); end; dmMain.Scan.Post; // Controle of EOF bereikt is van WristbandPrint if EOF then Abort else dmMain.WristbandPrint.Next; end; end; end; This code does NOT work: procedure WristbandPrintScan; begin if NOT dmMain.Scan.Active then dmMain.Scan.Active := TRUE; with dmMain.WristbandPrint do begin while NOT EOF do begin // Aanmaken records in scan database dmMain.Scan.Insert; dmMain.Scan.FieldByName('Name').Value := dmMain.WristbandPrint.FieldByName('Name').Value; dmMain.Scan.FieldByName('Color').Value := dmMain.WristbandPrint.FieldByName('Color').Value; dmMain.Scan.FieldByName('Text1').Value := dmMain.WristbandPrint.FieldByName('Text1').Value; dmMain.Scan.FieldByName('Text2').Value := dmMain.WristbandPrint.FieldByName('Text2').Value; dmMain.Scan.FieldByName('ValidYesNo').Value := dmMain.WristbandPrint.FieldByName('ValidYesNo').Value; dmMain.Scan.FieldByName('ValidDateStart').Value := dmMain.WristbandPrint.FieldByName('ValidDateStart').Value; dmMain.Scan.FieldByName('ValidDateEnd').Value := dmMain.WristbandPrint.FieldByName('ValidDateEnd').Value; dmMain.Scan.FieldByName('SequenceNumber').Value := dmMain.WristbandPrint.FieldByName('SequenceNumber').Value; dmMain.Scan.FieldByName('BarcodeNumber').Value := dmMain.WristbandPrint.FieldByName('BarcodeNumber').Value; dmMain.Scan.FieldByName('ScanStatus').Value := dmMain.WristbandPrint.FieldByName('ScanStatus').Value; dmMain.Scan.FieldByName('PrintDateTime').Value := dmMain.WristbandPrint.FieldByName('PrintDateTime').Value; dmMain.Scan.Post; // Controle of EOF bereikt is van WristbandPring if EOF then Abort else dmMain.WristbandPrint.Next; end; end; end; |
Thu, Nov 19 2020 12:20 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
I have no idea what you mean by "This code does NOT work" Looking at the code I can see one major difference "dmMain.WristbandPrint.First;" in the working one and not the other. If you alter the while test to while not dmMain.WristbandPrint,eof do begin you can get rid of "with dmMain.WristbandPrint do begin" Roy Lambert |
Thu, Nov 19 2020 12:32 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Peter
Since the structures are identical you might want to check out the SQL ... INSERT INTO ... its a lot neater & faster My manual reference is section 4.8 but my version of DBISAM is antique so just search for INSERT The SQL would be something like INSERT INTO "WristbandPrint" (SELECT * FROM "Scan" Roy Lambert |
Thu, Nov 19 2020 3:54 PM | Permanent Link |
Peter van Mierlo EVENTSOFT | Hi Roy
So I completely overlooked that one line ... thank you. I have now used your suggestion from the SQL and that is indeed much faster ... thank you Regards Peter |
This web page was last updated on Thursday, March 28, 2024 at 06:05 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |