has anyone run into problems reusing a query? I have a button that performs several updates. Instead of having a query for each update I clear the SQL, add the SQL, execute the query then clear the SQL, add different SQL and execute. I haven't had any issues with using this technique in the past. However, recently I have found that some queries get skipped! Not all the time, just sometimes. For example, I have the following process:
Yesterday, when this function was processed in the morning, the red section did not run, but the two bolded areas above and below did! I can tell this because the first update statement results are in the database and the PrintRollTime function prints a report. But the other update statement and insert statement, the results are missing. But when it was run in the afternoon, all processed completed normally.
any ideas?
Thanks,
leslie
Code:
procedure TfrmPanelRelease.btnProcessReleaseClick(Sender: TObject);
var
strPanelID : string;
begin
strPanelID := cbPanelList.Items[cbPanelList.ItemIndex];
with qryGetPanels do
begin
SQL.Clear;
SQL.Add('SELECT * FROM JMPTRIAL WHERE PANELID = ' + QuotedStr(strPanelID) + ' AND JURYSEL = ''N''');
Active := True;
if isempty then
begin
[b]SQL.Clear;
SQL.Add('UPDATE JMPNEWHOUR SET TIMEOUT = ' +
FormatDateTime('HHMM', dtpReleaseTime.Time) +
' WHERE JURNUM IN (SELECT JMPNEWHOUR.JURNUM FROM JMPNEWHOUR INNER JOIN JMPMAIN ON ' +
'JMPNEWHOUR.JURNUM = JMPMAIN.JURNUM WHERE SERVDAT = ' +
QuotedStr(frmMain.InfoArray[frmMain.TodayDate]) + ' AND FREE <> ''N'' AND PANELID LIKE ''' +
strPanelID + '%'')');
ExecSQL;
// above bolded statement executed[/b]
[b][COLOR=red]SQL.Clear;
SQL.Add('UPDATE JMPDLYPANL SET AVAILABL = ''N'', HRSRECRD = ''Y'' WHERE PANELID =' + QuotedStr(strPanelID)
+ ' AND SERVDAT = ' +
QuotedStr(frmMain.InfoArray[frmMain.TodayDate]));
ExecSQL;
frmMain.RecordChanges(frmMain.InfoArray[frmMain.JMSID], 'PANELS', 'SUCCESS:Release ' + strPanelID);
//above red statements did not executed[/color][/b]
[b]PrintRollTime(cbPanelList.Items[cbPanelList.ItemIndex], frmMain.InfoArray[frmMain.TodayDate]);
//bolded statements executed[/b]
end
else
begin
frmMain.RecordChanges(frmMain.InfoArray[frmMain.JMSID], 'PANELS', 'FAILED:Release ' + strPanelID);
ShowMessage('Panel ' + strPanelID + ' is assigned to ' +
FieldbyName('CASPRE').AsString + FieldByName('CASNUM').Asstring +
' and the jury has not been selected. Please select the jury before releasing the panel.');
end;
end;
Close;
end;
Yesterday, when this function was processed in the morning, the red section did not run, but the two bolded areas above and below did! I can tell this because the first update statement results are in the database and the PrintRollTime function prints a report. But the other update statement and insert statement, the results are missing. But when it was run in the afternoon, all processed completed normally.
any ideas?
Thanks,
leslie