Cannot update this query type

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
pbrzeski
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 04.03.2022, 11:41

Cannot update this query type

Post 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
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Cannot update this query type

Post 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
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: Cannot update this query type

Post by Fr0sT »

Side note: don't you get upset by typing all these giantic AddScenarioMenu.AddScenarioCategoryListTree.Selected.Parent.Text-like identifiers?
pbrzeski
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 04.03.2022, 11:41

Re: Cannot update this query type

Post 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 ;)
pbrzeski
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 04.03.2022, 11:41

Re: Cannot update this query type

Post by pbrzeski »

Thanks @marsupilami, this works fine.
Post Reply