RefreshRecord don't work. :(

I have agregate SQL, and i want to write my own refresh sql for this query. But it'sn't work :(

//qItems.FieldByName('normal_qty').AsInteger = 153
OnApplyRecord:

if Action='R' then
begin
qItemsRefresh.SetVariable('unit_id',qItems.GetVariable('unit_id'));//qItems hasn't field unit_id
qItems.DeclareQueryVariables(qItemsRefresh);
qItems.SetQueryVariables(qItemsRefresh);
qItemsRefresh.Execute;
//qItems.FieldByName('normal_qty').AsInteger = 153
//qItemsRefresh.FieldAsItneger('normal_qty') = 152
qItems.GetQueryVariables(qItemsRefresh);
//qItems.FieldByName('normal_qty').AsInteger = 153
Applied:=True;
end;

What happens?

And sorry for my English.
 
Oh! I find my trouble.

GetQueryVariables get items only from variables. And i set update sql as:
select sum(normal_qty) normal_qty
from norm_values
where unit_id = :unit_id
and item_id = :item_id
and (1=1 or :normal_qty = :normal_qty)

And OnApplyRecord as:
qItemsRefresh.SetVariable('unit_id',qItems.GetVariable('unit_id'));
qItems.DeclareQueryVariables(qItemsRefresh);
qItems.SetQueryVariables(qItemsRefresh);
qItemsRefresh.Execute;
qItemsRefresh.SetVariable('normal_qty',qItemsRefresh.FieldAsInteger('normal_qty' ));
qItems.GetQueryVariables(qItemsRefresh);
 
Back
Top