Jump to content

Wloochacz

Members
  • Content Count

    8
  • Joined

  • Last visited

Posts posted by Wloochacz


  1. OK, great, but...

    In this kind of application, fetching all data from the server and all BLOBs is definitely not a good solution...

    When I write a query, I don't always want to fetch all the data from the server - the first 100 records are enough for me (sure, you can move such a constant to the application configuration), and the rest on demand.

    Therefore, it might be better to set up FDQuery this way:

       Result.FetchOptions.Mode := fmOnDemand;
       Result.FetchOptions.Items :=[];
       Result.FetchOptions.Cache :=[];

    Besides, if I write such a query and I get an "out of memory" error message I really won't know what went wrong?
    Where did it run out of memory? On the server? In the application? If in the application, why?

     

    Oh well, and most importantly overall - if you always fetch all the data, the query execution time will be long.
    Or at least it will look like that, but in fact the execution of the query is say 0.1 sec and retrieving all the data is 10 sec.

     


  2. On 9/19/2021 at 11:52 AM, FranzB said:

    I use this  code  below to read an integer value  from an database

    
      aObject.IntValue := Fieldbyname('IntegerField').AsInteger;

    my code is functional, if there is an integer value stored.  

    Reading an  " "  empty field I get an exception failure. 

    What is the  best coding style to  avoid  this error  in an application ?  

     

    For your "ugly" database, such code will be the simplest and error-free:

    aObject.IntValue := StrToIntDef( Fieldbyname('IntegerField').AsString, 0);

     


  3. 5 hours ago, Javier Tarí said:

    There are no MVC or MVVM frameworks on Delph

    I'm sorry, do you know this project?
    https://github.com/grijjy/MvvmStarterKit

    It is not pure MVC, but MVVM :classic_wink:

     

    5 hours ago, Javier Tarí said:

    other than the DMVCframework, wich I believe is not thought for Windows UI apps

    Here full approval, DMVC (https://github.com/danieleteti/delphimvcframework) is not a project for VCL/FMX applications.

     

    5 hours ago, Javier Tarí said:

    And anyway, that kind of frameworks are not oriented to let a form use a TDataset or a TDatasource

     So IMHO, as of today, RAD and MVC/MVVM are not friends

    And yes and no.
    Please note that FMX is also not TDataSource oriented, it does not have DBAware controls known from VCL (e.g. TDBEdit) and instead LiveBinding mechanism is used.

    And in case of MVVM it can work very similarly.

     

    In my opinion, RAD is no one's friend and this friendship turns into hatred when the project is bigger and bigger... And it gets older and older, and it needs to be developed.

    After all, for decades we have been convinced that RAD is great! For everything!

    Just, it's bullshit.

    • Like 1

  4. Hello Jaca! :)

    There is no simple solution for that.

    However, I would suggest basing your own solution on the CopyDataSet code.
    Note that if you specify the coStructure parameter in the options of CopyDataSet method, you will get what you want.
    Almost ;-)


  5. On 2/21/2020 at 4:28 PM, Fr0sT.Brutal said:

    I saw multiple opinions that such big IN's are bad design. Where they come from?

    In general, this is true, especially in SQL executed on the server side, such as stored procedures, triggers, etc.

    And there, it's better to write like this:

    select
       A.*
    from foo1 A
    inner join foo2 B on (A.ID = B.ParentID)

    instead of this:

    select
       A.*
    from foo1 A 
    where A.ID in (select B.ParentID from foo2 B)

    Although the result will be identical.

    However, in some cases it is simply convenient.
    For example, in my application I pass an array of PrimaryKey values to ReportManager so that he can ask the server for the data he has selected on the list.

    It works like this:

    dfSelectToInSQL.thumb.gif.7e99cf5f46a69a0818807653bd61bf57.gif

     

    And where in SQL looks like this:

    where TD.IdDevice in (10,12,16,23)

    Simply clever :P

×