Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

TDataSetSQLStatement c esempio di “class helper” in Delphi.

Digital solution partner

TDataSetSQLStatement c esempio di “class helper” in Delphi.

Helpers are a way to extend a class without using inheritance, which is also useful for records that don’t allow inheritance at all.

Official documentation is available at:

https://docwiki.embarcadero.com/RADStudio/Sydney/en/Class_and_Record_Helpers_(Delphi).

I often found myself creating code to export a dataset or a single record with its values ​​in an SQL statement, and every time I wrote the code. Below I created a “class helper” for the dataset class that allows you to generate “insert/update/delete” statements.

Basically, once added to your units, the descendant TDataSets will have the “SQLStatement” and “SQLStatements” methods available to generate the desired SQL code.

If on a form we have a dataset called “DSrticoli” and we wanted to get the “Insert” code for the current record, it would be enough to write:

 

 

 

Helper class code: