This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.
Do more with
INSERT INTO Sold
(
ID,
QTY
)
VALUES
(
@ItemNo,
@Qty
);
UPDATE Stock
SET QTY = QTY - @Qty
WHERE ID = @ItemNo;
procedure TForm1.Button4Click(Sender: TObject);
var
stockQty, soldQty, remain: integer;
begin
MyQuery1.SQL.Text :=
'SELECT * FROM STOCKS.stocks WHERE id = :id';
MyQuery1.Prepare;
MyQuery3.SQL.Text :=
'UPDATE STOCKS.stocks SET QTY = :qty WHERE id = :id';
MyQuery3.Prepare;
MyQuery2.First;
while not MyQuery2.eof do
begin
MyQuery1.Close;
MyQuery1.ParamByName('id').AsString := dbText3.Caption;
MyQuery1.Open;
stockQty:=StrToInt(dbText2.Caption);
soldQty:=StrToInt(dbText4.Caption);
remain:= stockQty - soldQty;
Label1.Caption:=IntToStr(remain);
MyQuery3.ParamByName('ID').AsInteger := MyQuery1.ParamByName('ID').AsInteger;
MyQuery3.ParamByName('QTY').AsInteger := remain;
MyQuery3.ExecSQL;
// the following lines would set *ALL* stock from 5 to 4
//myUpdateSQL1.ModifySQL.Add('Update STOCKS Set qty=4 Where qty=5');
//myUpdateSQL1.ExecSQL(ukModify);
MyQuery2.Next;
end;
end;
Premium Content
You need an Expert Office subscription to comment.Start Free Trial