SQL Generator

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
cybsistemas
Posts: 118
Joined: Mon 12 Sep 2005 17:31
Location: Argentina

SQL Generator

Post by cybsistemas » Fri 17 Oct 2014 09:01

Is it possible to create a statement like sql generator which generates at runtime?

Something like:
myquery1.sql.text := select * from customers;
myquery1.execute;
"myquery1.generatesqlinsert"
showmessage(myquery1.sqlinsert.text);

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: SQL Generator

Post by ViktorV » Fri 17 Oct 2014 12:02

Here is a code example that demonstrates generating INSERT SQL statements at run-time:

Code: Select all

TDBAccessUtils.SQLGenerator(MyQuery1).SubstituteParamName := False;
ShowMessage(TDBAccessUtils.SQLGenerator(MyQuery1).GenerateSQL(TDAParamsInfo.Create(TDAParamInfo) , _stInsert, true));
Note that to run this code, you should add the CRAccess and DASQLGenerator units to the USES clause of your unit.
But we don't recommend to use this, because internal methods are used in the code and incorrect usage of them can lead to unpredictable consequences.

cybsistemas
Posts: 118
Joined: Mon 12 Sep 2005 17:31
Location: Argentina

Re: SQL Generator

Post by cybsistemas » Fri 17 Oct 2014 16:12

Thank you very much

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: SQL Generator

Post by ViktorV » Mon 20 Oct 2014 07:34

Feel free to contact us if you have any further questions.

Post Reply