Wloochacz
-
Content Count
8 -
Joined
-
Last visited
Posts posted by Wloochacz
-
-
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);
-
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/MvvmStarterKitIt is not pure MVC, but MVVM
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.
- 1
-
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 ;-) -
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:
And where in SQL looks like this:
where TD.IdDevice in (10,12,16,23)
Simply clever :P
-
On 2/21/2020 at 4:57 PM, Alexander Sviridenkov said:Such queries may be slow, After some number join is faster,
In e.g Firebird database, yes.
In MS SQL it does not matter.
-
On 2/21/2020 at 9:20 AM, aehimself said:Be careful with DB engine limitations. I can not count how many times my code failed, because Oracle can't handle more than 1000 entries in a single IN operator.
Indeed, but OP work with SQL Server.
-
Use the macro! 😉
fQ.SQL.Text := 'SELECT * FROM tTableName WHERE Status IN (!InValues) ORDER BY EventDate'; fQ.MacroByName('InValues').AsRaw := '''S'', ''R'''; fQ.Open;
- 1
TFDQuery Async execution aborts with out of memory
in Databases
Posted
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:
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.