John said:
I was suggesting that you *link* to the table that you're going to export. It
might be necessary to Import the textfile into a temporary table (so you can
use indexes on the join).
John W. Vinson [MVP]
I'm doing something wrong. I created a second table called tmpLog in the same
database(no linking, right?). The 5 fields that uniquely ID a record are indexed in
both tables. The "real" table is named Log. The inserts into both tables only work
the first time thru the loop. Subsequent execution doesn't produce any errors, but
doesn't insert any data either. Also the RecordsAffected is zero after "c := if
dbDAO.RecordsAffected" even tho data is inserted into the Log table. I'm curious to
see what the speed is, because this scheme requires 3 hits on the DB for each record,
whereas using FindFirst and only inserting on a NoMatch condition took hits 2 at
most. My SQL looks like this.
sql := 'INSERT into [TmpLOG] (U_Call, Call, LDate, Freq, Mode, R_RST, ' +
'R_Serial, S_RST, S_Serial, Power, Grid, Iota, CQ_zone, ITU_Zone, ' +
'ST, COunty, CID, Comment, QSL_R, QSL_S, QSL, Manager) ' +
'VALUES ("' + inRec.u_call + '", "' + inRec.call + '", #' + inRec.QDate + '#,' +
inRec.freq + ', "' + inrec.mode + '", "' + inRec.r_rst + '", "' +
inRec.r_serial + '", "' + inrec.s_rst + '", "' + inrec.s_serial + '", "' +
inRec.power + '", "' + inRec.grid + '", "' +
inRec.iota + '", "' + inrec.cq_zone + '", "' + inRec.itu_zone + '", "' +
inRec.state + '", "' + inrec.county + '", "' + inRec.CID + '", "' +
inRec.comment + '", "' + inrec.qsl_R + '", "' + inRec.qsl_S + '", "' +
inRec.qsl + '", "' + inrec.manager + '");';
dbDAO.Execute(sql);
c := if dbDAO.RecordsAffected;
sql := 'INSERT into [LOG] (U_Call, Call, LDate, Freq, Mode, R_RST, R_Serial, ' +
'S_RST, S_Serial, Power, Grid, Iota, CQ_zone, ITU_Zone, ST, COunty, ' +
'CID, Comment, QSL_R, QSL_S, QSL, Manager) Select tmplog.u_call, ' +
'tmplog.Call, tmplog.LDate, tmplog.Freq, tmplog.Mode, tmplog.R_RST, ' +
'tmplog.R_Serial, tmplog.S_RST, tmplog.S_Serial, tmplog.Power, ' +
'tmplog.Grid, tmplog.Iota, tmplog.CQ_zone, tmplog.ITU_Zone, tmplog.ST, ' +
'tmplog.County, tmplog.CID, tmplog.Comment, tmplog.QSL_R, tmplog.QSL_S, ' +
'tmplog.QSL, tmplog.Manager from [tmpLog] Left Join LOG on ' +
'Log.U_Call = tmplog.U_Call AND Log.Call = TmpLog.Call ' +
'AND Log.LDATE = TmpLog.lDate AND Log.Mode = TmpLog.Mode ' +
'AND Log.freq = TmpLog.freq WHERE Log.Call is null;';
dbDAO.Execute(sql);
if dbDAO.RecordsAffected > 0 then
result := true;
dbDAO.Execute('Delete * from TmpLog');