[Lazarus] Make table with TDataset structure

Marc Santhoff M.Santhoff at web.de
Mon Jun 22 00:22:52 CEST 2015


On So, 2015-06-21 at 14:01 -0700, aradeonas wrote:
> Yes I went with TSQLQuery but problem is how to get insert query
> automatically. So for example for Table1 without writing insert code I
> get insert SQL code.
> In lazarus database desktop tool,app do that but I can find out how to
> to do like that.

You normally can do that using SQL, too. But the syntax varies, for
SQLite this should be:

"CREATE TABLE <new table name> AS SELECT * from <template table name>
WHERE 0=1"

The where clause may be rejected, choose a clause that does not return
any columns or, if that doesn't create anything, one that returns only
one or a few rows and delete them in the new table after creation
("DELETE * FROM <new table name>").

See:

http://www.sqlite.org/lang_createtable.html

Paragraph "CREATE TABLE ... AS SELECT Statements"

Cheers,
Marc

-- 
Marc Santhoff <M.Santhoff at web.de>





More information about the Lazarus mailing list