Jump to content

Osama Ghazal

Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

3 Neutral
  1. Osama Ghazal

    TFDUpdateSQL Problem onInsert

    @programmerdelphi2k Ok, I Update the InsertSQL as the following: INSERT HIGH_PRIORITY INTO products (ProductID, Barcode, ProductName, CategoryID, LevelNo, ProductType, QtyHasDigits, IsService, MinQty, UserID) VALUES (:ProductID, :Barcode, :ProductName, :CategoryID, 4, 0, 0, 0, 0, 1); Insert INTO pricelists (ProductID, SalePrice, MinSalePrice, Service) VALUES (:ProductID, :SalePrice, :MinSalePrice, :Service) and it is success. Thanks you
  2. Osama Ghazal

    TFDUpdateSQL Problem onInsert

    Thanks, I have many solutions for this but I am trying to optimize my code and using less code as I can. I will look for other solution.
  3. Osama Ghazal

    TFDUpdateSQL Problem onInsert

    I put it already in this event qryProductsBeforePost : qryProductsProductID.Value := fdConnection1.ExecSQLScalar('SELECT IFNULL(MAX(ProductID) + 1, 1) AS NewID FROM products'); and it gives me a new id 151
  4. Osama Ghazal

    Good book about FireDAC

    I talked about it, not many peoples says that it is deep and it not cover a many topics, only few
  5. Osama Ghazal

    Good book about FireDAC

    Hi All, is there is any documentation or books for firedac that help me to upgrade my knowledge? I look for FireDAC in Depth, but I found the most topics on fdmemorytable, and there is nothing deep. and the Embarcadero documentations and samples are very bad and complex, there is no explains enough. I have recordesd many videos on youtube and I feel that I am not strong enough in FireDAC. so, what is the solution?
  6. Osama Ghazal

    TFDUpdateSQL Problem onInsert

    Hi All, I am using MySQL Database and I create a query called qryProducts like this: SELECT p.ProductID, p.Barcode, p.ProductName, p.CategoryID, p.LevelNo, p.ProductType, p.UserID, p.IsService, pl.SalePrice, pl.MinSalePrice, pl.Service FROM products p LEFT JOIN pricelists pl ON p.ProductID = pl.ProductID pricelists table primarykey is ProductID and it is related with products by the ProductID field I connect the query with a datasource and with dbEdits to fill the values I am using also FDUpdateSQL and i fill InsertSQL with this sentence: Insert INTO pricelists (ProductID, SalePrice, MinSalePrice, Service) VALUES (:ProductID, :SalePrice, :MinSalePrice, :Service) the DFM file for qryProducts is like this object qryProducts: TFDQuery BeforePost = qryProductsBeforePost Connection = FDConnection1 UpdateOptions.KeyFields = 'ProductID' UpdateObject = FDUpdateSQL2 SQL.Strings = ( 'SELECT' ' p.ProductID,' ... qryProductsBeforePost : qryProductsProductID.Value := fdConnection1.ExecSQLScalar('SELECT IFNULL(MAX(ProductID) + 1, 1) AS NewID FROM products'); and the result is ok = 151 this productid is not exists I write qryProducts.Append; and fill the values by dbEdits then I write qryProducts.Post; it gives me this error: [FireDAC][Phys][MySQL] Cannot add or update a child row: a forign key contraint fails(pricelist', Constraint 'pricelists_prod...'foreign key ('productid'' references 'products'(productID'on delete cascade on update cascade. i tried many solutions as I put a UpdateOptions.KeyFields = 'ProductID' and remove it later, i put the update table pricelists and so on, with no result
×