3 transform - edit mode, temp=0.2; prompt "Format the code nicely, remove obsolete and out-of-place comments."
20 removals
53 lines
10 additions
39 lines
function fnGetSqlConditions(const ASqlColumnName: String;
function fnGetSqlConditions(const ASqlColumnName: String;
const ADatePicker: TDatePickerFrame;
const ADatePicker: TDatePickerFrame;
const ATimePickerFrom, ATimePickerTo: TTimePickerFrame): String;
const ATimePickerFrom, ATimePickerTo: TTimePickerFrame): String;
begin
begin
Result := '';
Result := '';
// filtering DATA_INS by creation date range
if (ADatePicker.DateFrom <> 0) then begin
if (ADatePicker.DateFrom <> 0) then begin
if (not ATimePickerFrom.fnIsEmpty()) then
if (not ATimePickerFrom.fnIsEmpty()) then
Result := Result + Format(' and %s >= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateFrom + ATimePickerFrom.Value))])
Result := Result + Format(' and %s >= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateFrom + ATimePickerFrom.Value))])
else
else
Result := Result + Format(' and %s >= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateFrom))]);
Result := Result + Format(' and %s >= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateFrom))]);
end;
end;
if (ADatePicker.DateTo <> 0) then begin
if (ADatePicker.DateTo <> 0) then begin
if (not ATimePickerTo.fnIsEmpty()) then
if (not ATimePickerTo.fnIsEmpty()) then
Result := Result + Format(' and %s <= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateTo + ATimePickerTo.Value))])
Result := Result + Format(' and %s <= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateTo + ATimePickerTo.Value))])
else
else
Result := Result + Format(' and %s <= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateTo))]);
Result := Result + Format(' and %s <= %s', [ASqlColumnName, QuotedStr(fnDateToSqlStr(ADatePicker.DateTo))]);
end;
end;
end;
end;
procedure TfmWebLogForm.prOpenSQL;
procedure TfmWebLogForm.prOpenSQL;
const
const
C_SQL = 'select hdl_d11, hdl_d02_d11, hdl_007_d11, hdl_d11_d11, event_d11, '
C_SQL = 'select hdl_d11, hdl_d02_d11, hdl_007_d11, hdl_d11_d11, event_d11, '
+ ' time_d11, '
+ ' time_d11, '
+ ' remote_ip_d11, user_d11, session_id_d11, url_d11, content_type_d11, content_d11'
+ ' remote_ip_d11, user_d11, session_id_d11, url_d11, content_type_d11, content_d11'
+ ' from tweb_srv_log_d11 d11 where'
+ ' from tweb_srv_log_d11 d11 where'
+ ' d11.hdl_d11_d11 is null';
+ ' d11.hdl_d11_d11 is null';
begin
begin
frmSQLGridFrame1.SQLText := C_SQL;
frmSQLGridFrame1.SQLText := C_SQL;
// add query filters for:
// - filtering HDL_D02
// - filtering DATA_INS by creation date range (incl time)
// - filtering TIME by execution date range (incl time)
// immediately after that, open query
// use QuotedStr and fnDateToSqlStr(TDateTime) to format TDateTime parameters for the query
// if time is not empty, use property Value to extract it from time picker
// time must be added to date before casting to string
//filtering HDL_D02
if (HdlD02 <> 0) then
if (HdlD02 <> 0) then
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText + Format(' and HDL_D02_D11 = %d', [HdlD02]);
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText + Format(' and HDL_D02_D11 = %d', [HdlD02]);
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText
// filtering DATA_INS by creation date range, filtering TIME by execution date range
+ fnGetSqlConditions('DATA_INS_D11', dpCreated, edtTimeCreatedFrom, edtTimeCreatedTo)
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText + fnGetSqlConditions('DATA_INS_D11', dpCreated, edtTimeCreatedFrom, edtTimeCreatedTo) + fnGetSqlConditions('TIME_D11', dpExecuted, edtTimeExecutedFrom, edtTimeExecutedTo);
+ fnGetSqlConditions('TIME_D11', dpExecuted, edtTimeExecutedFrom, edtTimeExecutedTo)
+ ' order by DATA_INS_D11 desc';
frmSQLGridFrame1.SQLText := frmSQLGridFrame1.SQLText + ' order by DATA_INS_D11 desc';
frmSQLGridFrame1.prOpenQuery;
frmSQLGridFrame1.prOpenQuery;
frmSQLGridFrame1.OnRowRefresh := prRowInfo;
frmSQLGridFrame1.OnRowRefresh := prRowInfo;
frmSQLGridFrame1.VisibleColumnsList.Values['DATA_INS_D11'] := 'Created';
frmSQLGridFrame1.VisibleColumnsList.Values['DATA_INS_D11'] := 'Created';
end;
end;