Page 1 of 1

SQL Generator

Posted: Fri 17 Oct 2014 09:01
by cybsistemas
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);

Re: SQL Generator

Posted: Fri 17 Oct 2014 12:02
by ViktorV
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.

Re: SQL Generator

Posted: Fri 17 Oct 2014 16:12
by cybsistemas
Thank you very much

Re: SQL Generator

Posted: Mon 20 Oct 2014 07:34
by ViktorV
Feel free to contact us if you have any further questions.