절대 데이터베이스의 BatchMove
은 두 개의 TTable
구성 요소가 필요한 이전의 BDE TBatchMove
을 모델링 한 것으로 보입니다. IIRC, TQuery
과 작동하지 않았지만 잘못 기억하고있을 수 있습니다. (BDE는 10 년 이상 사용되지 않아 Delphi 1부터 사용하지 않았습니다.)
BatchMove
은 필요하지 않습니다.
// Copy rows into destination
ABSTQuery1.SQL.Text := 'INSERT INTO DestTable'#32 +
'(SELECT * from MYTABLE where DATE BETWEEN :a1 and :a2)';
ABSTQuery1.Parameters.ParamByName ('a1').AsDate := DateTimePicker1.Date;
ABSTQuery1.Parameters.ParamByName ('a2').AsDate := DateTimePicker2.Date;
ABSTQuery1.ExecSql;
ABSTQuery1.Close;
// Remove them from source (you said "move", after all)
ABSTQuery1.SQL.Text := 'DELETE FROM MyTable'#32 +
`WHERE Date BETWEEN :a1 and :a2';
ABSTQuery1.Parameters.ParamByName ('a1').AsDate := DateTimePicker1.Date;
ABSTQuery1.Parameters.ParamByName ('a2').AsDate := DateTimePicker2.Date;
ABSTQuery1.ExecSql;
ABSTQuery1.Close;
첫 번째 SQL 문에서 대상 테이블의 이름으로 DestTable
교체 : 당신은 당신의 단일 쿼리 (간결함을 위해 생략 예외 처리) 모든 것을 할 수 있습니다.
더 나는 절대 데이터베이스를 사용하지 않은,하지만 자신의 SQL 지원, 스크립트가 포함 된 경우 (내가 당신까지 그 연구를 떠날거야 - 문서 위의 링크) on-line manual
절대 데이터베이스의 정보와 여러 문, 당신 한 번의 패스로 처리 할 수 있습니다.
// Note addition of `;` at end of each SQL statement
// and change in param names for second statement.
// Some DBs will allow you to just use one pair, and
// set the value for each once. Some require setting
// each twice, and some require unique param names.
// Check the documentation for Absolute DB.
//
ABSTQuery1.SQL.Text := 'INSERT INTO DestTable'#32 +
'(SELECT * from MYTABLE where DATE BETWEEN :a1 and :a2);'
'DELETE FROM MyTable WHERE Date BETWEEN :d1 and :d2;';
ABSTQuery1.Parameters.ParamByName ('a1').AsDate := DateTimePicker1.Date;
ABSTQuery1.Parameters.ParamByName ('a2').AsDate := DateTimePicker2.Date;
// New param names for second pass
ABSTQuery1.Parameters.ParamByName ('d1').AsDate := DateTimePicker1.Date;
ABSTQuery1.Parameters.ParamByName ('d2').AsDate := DateTimePicker2.Date;
ABSTQuery1.ExecSQL;
ABSTQuery1.Close;
왜 이렇게 많은 델파이 버전이 태그되어 있습니까? –