我要实现的是A任务表,B任务执行状态两表关联查询后,得到A表中能执行的数据,查询出来的结果确实是A表中能执行任务的数据,
但是在向B表中插入这条A表数据执行状态的时候,插入B表中的数据ID不是之前查询A表出来数据的ID,
下面附上代码,求大大们指点
//定义了任务运行表插入数据操作过程
procedure TForm1.InsertData(exeid,status,starttime,endtime,result : string);
begin
qry3.Close;
qry3.SQL.Clear;
qry3.SQL.Text:= 'insert into task_operation(execute_id,status,start_time,end_time,result_log) values(:execute_id,:status,:start_time,:end_time,:result_log)';
qry3.Parameters.ParamByName('execute_id').Value := exeid;
qry3.Parameters.ParamByName('status').Value := status;
qry3.Parameters.ParamByName('start_time').Value := starttime;
qry3.Parameters.ParamByName('end_time').Value := endtime;
qry3.Parameters.ParamByName('result_log').Value := result;
qry3.ExecSQL;
end;
//这就是AB连接查询然后执行插入的操作
qry4.Close;
qry4.SQL.Clear;
qry4.SQL.Text := 'select execute_id,weburl from task_description where task_description.excuteperiod_daily <= (select right(now(),8)) and task_description.execute_id not in' +
'(select execute_id from task_operation where task_operation.start_time between (SELECT CAST(CAST(SYSDATE()AS DATE)AS DATETIME)) and (SELECT CAST((CAST(SYSDATE()AS DATE) + INTERVAL 1 DAY)AS DATETIME)))';
qry4.Open;
qry4.First;
while not qry4.Eof do
begin
weburl := qry4.FieldByName('weburl').AsString +'#'+ qry4.FieldByName('execute_id').AsString;
start_time := FormatDateTime('yyyy-MM-dd hh:mm:ss',now);
Form1.showWeburl(weburl);
edt2.Text := weburl;
edt1.Text := qry4.FieldByName('execute_id').AsString; ==〉此处的ID还是AB联结查询结果的ID
exeid := qry4.FieldByName('execute_id').AsString;
form1.insertData(exeid,'执行中',start_time,'','任务正在执行中');
这边插入数据后,id就变了,请大神不吝赐教。