Multiple statements and parameters
Posted: Tue 29 Sep 2009 19:59
Just a quick question on what is the best way to achieve the following:
I wish to populate a query with a few sql statements (with parameters) before actually executing them. Is there a way to have each statement with parameters compiled when I add them or do I have to assign unique parameters for each statement?
For example
And that will execute those statements compiled with their parameters.
Thanks.
I wish to populate a query with a few sql statements (with parameters) before actually executing them. Is there a way to have each statement with parameters compiled when I add them or do I have to assign unique parameters for each statement?
For example
Code: Select all
Query.SQL.Add('INSERT INTO table VALUES(:id, :name);');
Query.Params[0].AsInteger := 1;
Query.Params[1].AsString := 'First';
// compile here
Query.SQL.Add('INSERT INTO table VALUES(:id, :name);');
Query.Params[0].AsInteger := 2;
Query.Params[1].AsString := 'Second';
// compile here
Query.Execute;
Thanks.