[Lazarus] Make table with TDataset structure

Marc Santhoff M.Santhoff at web.de
Mon Jun 22 18:26:16 CEST 2015

On Mo, 2015-06-22 at 04:11 -0700, aradeonas wrote:
> Thank you Marc,very interesting point but now Im talking about INSERT

Sorry, I read too fast over your mail.

> I want to make insert sql command for a table ,for example :
> INSERT INTO table1(Filed1,Filed2) VALUES(:Filed1,:Filed2);
> I know its possible because Lazarus data desktop do this but I count
> find out how and I thought with my self maybe It's Maker or others who
> work with its source can help me in this.

If your table is created and you have got a TSQLQuery or the like
attached and opened, you can iterate over it's FieldDefs property.

It should work similar to this pseudocode:

strinsertsql := 'INSERT INTO <table name> VALUES (';

for i=0 to Query.Fielddefs.Count do begin
	strname := FieldDefs[i].Name;
	strtype := map_type_from_laz_to_sqlite( FieldDefs[i].DataType;
	strinsertsql := strinsertsql + ', ' + strname;

... and so on.

Marc Santhoff <M.Santhoff at web.de>

More information about the Lazarus mailing list