dbexpress 的主/细节问题

发布于 2024-10-08 05:02:58 字数 600 浏览 0 评论 0原文

我有一个使用 firebird 2.3 用 Delphi 2010 / dbExpress 编写的主/详细应用程序 我发现了一个问题

如果我在详细信息中有两行或三行或更多相同的数据行,更改其中一行中的任何数据也会更改其他行上的数据,我猜这是因为更新仅使用invoice_id和serial由于键和数据在两种情况下都相同,因此更新是在两种情况下完成的。

主数据 发票 ID、序列号、客户 ID、日期 1、A、1.12 / 12 / 2010

详细数据 Invoice_id、序列号、数量、描述、价格 1、A、10、几盒东西,52.52 1, A, 10, BOXES OF SOME STUFF, 52.52

我想我可以通过使用字段 ltes name ir line_no 来解决此问题,其中每行都有不同的编号,因此可以区分数据以进行更新,如下所示:

Line_no , Invoice_id, 序列号, 数量, 描述, 价格 1.1,A,10,几盒东西,52.52 2.1,A,10,一些东西的盒子,52.52

所以信息是相同的,但它也有 line_no 来区分更新中的信息

任何人都知道在客户端、客户端数据集中执行此操作的任何方法,

非常感谢非常和问候

I have a master / detail application written in Delphi 2010 / dbExpress using firebird 2.3
I have found a problem

If I have two or three or more identical lines of data in the detail, changing any data in one of them also changes the data on the other lines, I guess this is because the update uses only the invoice_id and serial as keys and the data is equal in both cases, the update is done in the two cases.

Master Data
Invoice_id, serial, customer_id, date
1, A, 1.12 / 12 / 2010

Detail Data
Invoice_id, serial, qty, description, Price
1, A, 10, BOXES OF SOME STUFF, 52.52
1, A, 10, BOXES OF SOME STUFF, 52.52

I guess I can fix this by using a field ltes name ir line_no in which each line would have a different number and so the data could be distinguished to make the update as follows:

Line_no, Invoice_id, serial, qty, description, Price
1.1, A, 10, BOXES OF SOME STUFF, 52.52
2.1, A, 10, BOXES OF SOME STUFF, 52.52

So the information is the same but it has also the line_no to differentiate the information in the update

Anyone know any way to do this on the client side, in the clientdataset,

Thank you very much and greetings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃气十足 2024-10-15 05:02:58

似乎您的详细表中没有主键(假设invoice_id是主表的外键。为了确保FireBird(或任何dbExpress连接的数据库)更新正确的记录,您应该添加主键(autoinc字段)到明细表。

It seems that there is no primary key in your detail table (assuming invoice_id is the foreign key to the master table. To make sure that FireBird (or any dbExpress connected database) updates the correct record you should add a primary key (autoinc field) to the detail table.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文