Спасибо за ответы, но это-то я понимаю. что для изменяющихся параметров. Мне надо было узнать где посмотреть этот параметр, уже заданный до меня. Всё оказалось гораздо проще нужно было на форме искать выбрав компонент IBDataSet и открыть его свойство SelectSQL. Там всё тело запроса и лежит.
Но появился ещё один вопрос по запросам.
Код:
begin
Result := '';
if ((dtFrom_Period.Value <> null) and (dtTo_Period.Value <> null)) then
Result := Str_SQL_Add(Result, ' and ', '(jo.off_date >= ''' + DateToStr(TDate(dtFrom_Period.Value)) + ''' and jo.off_date <= ''' + DateToStr(TDate(dtTo_Period.Value)) + ''') ');
if (DBLookupComboboxFW1.KeyValue <> null) and (DBLookupComboboxFW1.KeyValue <> -1) then
Result := Str_SQL_Add(Result, ' and ', '(jo.providerid = ' + string(DBLookupComboboxFW1.KeyValue) +')');
if (DBLookupComboboxFW2.KeyValue <> null) and (DBLookupComboboxFW2.KeyValue <> -1) then
Result := Str_SQL_Add(Result, ' and ', 'left join ha_uchastok_house_table uht on uht.houseid = joa.houseid and ' + ' uht.uchastok_table_id = ' + string(DBLookupComboboxFW2.KeyValue));
if (DBLookupComboboxFW3.KeyValue <> null) and (DBLookupComboboxFW3.KeyValue <> -1) then
Result := Str_SQL_Add(Result, ' and ', '(select ADDRESS_NAME from HA_OBJECT_GET_ADDRESS(joa.houseid)) like '''+ DBLookupComboboxFW3.Text + '%'' ');
if (DBLookupComboboxFW8.KeyValue <> null) and (DBLookupComboboxFW8.KeyValue <> -1) then
Result := Str_SQL_Add(Result, ' and ', '(joa.houseid = ' + string(DBLookupComboboxFW8.KeyValue) + ')');
if (DBNumberEditFW15.Value <> null) and (DBNumberEditFW15.Value <> '') then
Result := Str_SQL_Add(Result, ' and ', '(joa.flat_num = ' + string(DBNumberEditFW15.Value) + ')');
if (DBEditFW8.Value <> null) and (DBEditFW8.Value <> '') then
Result := Str_SQL_Add(Result, ' and ', '(joa.flat_prefix = ' + #39 + DBEditFW8.Value + #39 + ')');
end;
Ругается на поле joa.houseid, нужно подключить таблицу:
ha_journal_outages_address joa, но как не могу понять.
P.s.
Str_SQL_Add(a, b, c: string) :string; - это функция проверки передаваемой переменной Result если передаваемая переменная не пустая, то перед строкой добавляется ' and '