Page 1 of 1

Cannot update this query type

Posted: 04.03.2022, 11:51
by pbrzeski
Hi,

My project migrated from the older ZEOS to 7.2.14-release.
Before that, everything was working fine. Currently, I can't change the checkbox status because it ends with the error "Cannot update this query type".
I attach a code snippet in which there is a status change.
I am asking for verification why the previous solution stopped working now and possibly for a hint on how to change the status now.


procedure SetDBGrid(selectedSearchByComboIndex: integer);
begin
  if AddScenarioMenu.AddScenarioCategoryListTree.Selected.Text <> 'Parametry' then
  begin
    if (AddScenarioMenu.AddScenarioCategoryListTree.Selected.Parent.Text = 'Parametry')
       and (AddScenarioMenu.AddScenarioCategoryListTree.Selected.Text <> 'Moduły') then
      lWHEREA:= ' and nops_pop is null '
    else if (AddScenarioMenu.AddScenarioCategoryListTree.Selected.Text = 'Moduły') then
           lWHEREA:= ' and 1 = 1 '
         else
           lWHEREA:= ' and nops_pop is not null ';
    lWHERE:= '      and nops in (select nops from sops where napp = 22 '+lWHEREA+'start with nazw = '+
             ''''+AddScenarioMenu.AddScenarioCategoryListTree.Selected.Text+''''+' connect by prior nops = nops_pop)';
  end
  else
    lWHERE:= ' and 1 = 1 ';

  if selectedSearchByComboIndex = 1 then
    lWHERESEARCH:= '      and upper(nazw) like '+''''+ReplaceStr(AddScenarioMenu.AddScenarioListSearch.Text,'''','''''')+'%'+''''
  else if selectedSearchByComboIndex = 0 then
         begin
           lWHERESEARCH:= '      and upper(zmie) like '+''''+ReplaceStr(AddScenarioMenu.AddScenarioListSearch.Text,'''','''''')+'%'+''''
         end;

  MenuGlowne.ZQueryPROD.SQL.Text:= 'select zmie as "Zmienna", nazw as "Nazwa",'+sLineBreak+
                   '       decode(sopd.tpop, ''ST'', ''Tekst'', ''IN'', ''Liczba całkowita'', ''FL'', ''Liczba rzeczywista'','+sLineBreak+
                   '       ''DT'',''Data'',''LG'',''Wartość logiczna'',''DR'',''Katalog'',''EN'',''Wyliczeniowa'','+sLineBreak+
                   '       ''IC'',''Zbiór wartości'',''CS'',''Zakodowany tekst'') as "Typ",'+sLineBreak+
                   '       (case when sopd.tpop = ''LG'' then nvl(doms,''NIE'') when sopd.tpop = ''EN'' then nvl(doms,''0'') when sopd.tpop = ''IN'' then nvl(sopd.doms,''0'') else nvl(doms,''???'') end) as "Wart. domyślna",'+sLineBreak+
                   '       nvl(decode(substr(dost,5,1),''1'',''O'','''')||decode(substr(dost,4,1),''1'',''S'','''')'+sLineBreak+
                   '       ||decode(substr(dost,3,1),''1'',''M'','''')||decode(substr(dost,2,1),''1'',''R'','''')'+sLineBreak+
                   '       ||decode(substr(dost,1,1),''1'',''N'','''')||decode(wrzm,''N'','''',''T'',''W''),'' '') as "Określone",'+sLineBreak+
                   '       ''0'' as "Status"'+sLineBreak+
                   'from sopd'+sLineBreak+
                   'where napp = 22'+sLineBreak+
                   lWHERE+sLineBreak+
                   lWHERESEARCH+sLineBreak+
                   'order by zmie';
  ;

  MenuGlowne.ZQueryPROD.Active:= true;

  AddScenarioMenu.AddScenarioOptionListDataSource.DataSet:= MenuGlowne.ZQueryPROD;

  while not AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.EOF do
    begin
      AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.Fields[5].ReadOnly:= false;
      AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.Edit;
      AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.FieldByName('Status').AsString:= IsCheckedZMIE(AddScenarioMenu.CheckedRows,AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.FieldByName('Zmienna').AsString);
      AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.Post;
      AddScenarioMenu.AddScenarioOptionListDataSource.DataSet.Next;
    end;

  AddScenarioMenu.AddScenarioOptionListDBGrid.DataSource:= AddScenarioMenu.AddScenarioOptionListDataSource;

end; 
the problem is in the bold part of the code, it worked before

Re: Cannot update this query type

Posted: 05.03.2022, 10:09
by marsupilami
Hello pbrzeski,

Maybe we changed to be more strict in the type of queries we can update. Your query contains a lot of fields that are calculated and Zeos might determine that it cannot update that kind of query. I suggest you add a TZUpdateSQL to the Query. This will make all fields updateable. Changes are only posted to the database if you fill in any of the InsertSQL, ModifySQL, DeleteSQL and RefreshSQL properties. Any operation where you don't fill in a command, will not be sent to the database.

Best regards,

Jan

Re: Cannot update this query type

Posted: 05.03.2022, 11:28
by Fr0sT
Side note: don't you get upset by typing all these giantic AddScenarioMenu.AddScenarioCategoryListTree.Selected.Parent.Text-like identifiers?

Re: Cannot update this query type

Posted: 07.03.2022, 08:56
by pbrzeski
Maybe a bit of a poor solution with long identifiers, but my point is that the identifier should immediately tell me what it is and what it is for, even if I look at the code after a long break ;)

Re: Cannot update this query type

Posted: 07.03.2022, 10:04
by pbrzeski
Thanks @marsupilami, this works fine.