Page 1 of 1

Use ibcupdate component to insert/update a lot of records

Posted: Fri 19 Mar 2010 18:37
by alosak
hi,
I'm new in ibdac components. I'm not able to set parameters for a sql statement.
Below an example:

ibcQuery1.sql.Text:='select * from mytable';


ibcupdatesql1.InsertSQL := 'insert into mytable (field1, field2) values (:par1, :par2)';

How to set par1 and par2 ? I mean something like this :
ibcupdatesql1.SQL[ukInsert].parambyname('par1').asstring := 'valore';

Thanks in advance for any help.

Posted: Mon 22 Mar 2010 13:20
by Dimon
TUniUpdateSQL does not allow using parameters of SQL properties. In order to get access to those parameters you should use the Object properties like InsertObject, UpdateObject, and DeleteObject. You can assign the TUniSQL component to these properties to perform advanced adjustment of the insert/update/delete operations.

Also note: SQLInsert statement can be parameterized queries. If the names of the parameters are the same as those of fields, then values from fields will be set in parameters automatically. Parameters prefixed with OLD_ allow using current values of fields prior to an actual operation.

Posted: Tue 23 Mar 2010 10:52
by Dimon
Also, you can handle the TCustomDADataSet.BeforeUpdateExecute event and set parameters value, like this:

Code: Select all

Params.ParamByName(ParamName).AsString := s;