最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

firedac - Suggestion for the correct design (products list – product card) - Stack Overflow

programmeradmin0浏览0评论

I need help with a rather trivial task – fully rollback a creation of new product (CachedUpdate = True) when used two separate queries.

  • Products list (list form/grid) – pretty short/light query, let’s say “number” and “name”.
  • Particular product (productcard/edit form) – larger query, let’s say translation, nutrition fact and possibly detail tables – prices, bar codes etc.

Even without detail tables I want to separate those to queries – in list I do not need to much fields. In first version my workflow was as follows:

  • Product list. If I need to edit – nothing special. I was able to update exact row (by calling RefreshRecord) in list if successfully was updated product in edit form.
  • If I need to add new product – pain in the ass. My decision was to do in the same way (as described in in the previous sentence). So, I did it with that code:
        var oRow := mtTable.Table.NewRow;  //RowState here = rsDetached
        oRow.ValueO[mtTable.Table.Columns.ColumnByName('Id')] := MyKey;
        mtTable.Table.Rows.Add(oRow); //rowState here = rsEdited
    
    Problem here is RefreshRecord. It does nothing if RowState is rsDetached/rsInserted.

Some detail found here: /

Maybe there is a problem from the beginning. How to make first query reflecting data from second one, if new product was added? How to assign id from detail table (if was added new row) to new one? Can I do what I want but in more elegant way?

发布评论

评论列表(0)

  1. 暂无评论