Subject | Re: [IBO] TIBOQuery Problem ? |
---|---|
Author | Helen Borrie |
Post date | 2005-06-09T07:40:26Z |
At 09:00 PM 8/06/2005 -0600, you wrote:
1) you have a stray table alias at the beginning of the statement ("r") -
it needs to be removed
2) You are trying to perform a post-assignment to the Text property of a
TStringList. The correct way to assign strings to a stringlist is with the
Add() method of the stringlist. You should treat the Text property as a
read-only property, and never try to assign to it (even though in fact you
*can* but it is a one-shot operation). So the pieces you are trying to
tack onto the end of the Text property never actually make into the
stringlist at all.
What you *could* do is read the Text property into a string variable,
append to that string and then re-assign the whole thing to the Text
property. But this is messy and it is not how stringlists were designed to
be used. It's also difficult to maintain.
Try changing these statements to:
qryGeneral2->Close();
qryGeneral2->SQL->Strings->Clear;
qryGeneral2->SQL->Strings->Add("update period_value_daily set sale = sale -
:sale, on_hand = on_hand + :quantity, qty_sold_out = qty_sold_out -
:quantity )";
qryGeneral2->SQL->Strings->Add( ",cost_of_sale = cost_of_sale - ( :avgcost *
:quantity ) ");
qryGeneral2->SQL->Strings->Add(" where trackingdate = :saledate and
item_code = :itemcode");
qryGeneral2->Prepare();
Helen
>Hello Jason,Yes, two problems I see here:
>
>TIBOQuery .. Version 4.5B
>
>qryGeneral2->Close();
>
>qryGeneral2->SQL->Text = "update period_value_daily r set sale = sale -
>:sale, on_hand = on_hand + :quantity, qty_sold_out = qty_sold_out -
>:quantity ";
>
> qryGeneral2->SQL->Text += ",cost_of_sale = cost_of_sale - ( :avgcost *
>:quantity ) ";
> qryGeneral2->SQL->Text +="where trackingdate = :saledate and item_code =
>:itemcode";
> qryGeneral2->Prepare();
>
> for (int i = 0;i < dtm_Sales->qryGeneral2->ParamCount; i++)
> ShowMessage(String(i) + " - " +
>dtm_Sales->qryGeneral2->Params->Items[i]->Name);
>
>Results only in
> 0 - sale
> 1 - quantity
>
>and no more
>
>salesdate, avgcost and itemcode are not part of the Params
>
>Any ideas ?
1) you have a stray table alias at the beginning of the statement ("r") -
it needs to be removed
2) You are trying to perform a post-assignment to the Text property of a
TStringList. The correct way to assign strings to a stringlist is with the
Add() method of the stringlist. You should treat the Text property as a
read-only property, and never try to assign to it (even though in fact you
*can* but it is a one-shot operation). So the pieces you are trying to
tack onto the end of the Text property never actually make into the
stringlist at all.
What you *could* do is read the Text property into a string variable,
append to that string and then re-assign the whole thing to the Text
property. But this is messy and it is not how stringlists were designed to
be used. It's also difficult to maintain.
Try changing these statements to:
qryGeneral2->Close();
qryGeneral2->SQL->Strings->Clear;
qryGeneral2->SQL->Strings->Add("update period_value_daily set sale = sale -
:sale, on_hand = on_hand + :quantity, qty_sold_out = qty_sold_out -
:quantity )";
qryGeneral2->SQL->Strings->Add( ",cost_of_sale = cost_of_sale - ( :avgcost *
:quantity ) ");
qryGeneral2->SQL->Strings->Add(" where trackingdate = :saledate and
item_code = :itemcode");
qryGeneral2->Prepare();
Helen