axapta 表插入/更新

发布于 2024-09-16 17:17:38 字数 425 浏览 4 评论 0原文

再次出现 axapta 问题(在 ax 2009 和 sql-server 2008 r2 上运行): 插入或更新的数据集存储在相关数据库中的确切时间点是什么?

目的是调用 sql-server 上的存储过程,将数据从 ax-table (例如 inventtable )传输到另一个(不是用 axapta 生成的)表。在表方法之一上通过 odbc 从 axapta 执行存储过程(即使在 super() 调用之后)会触发存储过程,但在通过 smss 选择时找不到刚刚在 axapta 中添加或修改的数据( select *来自 dbo.inventtable )。

我知道数据已经存储在数据库中的唯一地方是相关表单上数据源上的方法,但这会很丑陋,因为数据可以通过 ax 中的 n 个表单进行编辑。

那么有没有办法将调用放在表格上而不是表单的数据源上?

感谢您的提前提示!

and once again an axapta-question ( running on ax 2009 and sql-server 2008 r2 ):
which is exactly the point of time, when inserted or updated datasets are stored in the regarding database?

the aim is to call a stored procedure on the sql-server which transfers data from the ax-tables ( eg inventtable ) to another ( not generated with axapta ) table. executing the stored procedure via odbc from axapta on one of the table-methods ( even after super() call ) triggers the stored procedure, but the data which was just added or modified in ax isn't found while selecting via smss ( select * from dbo.inventtable ).

the only place i know yet where the data is already stored in db is on the methods on the datasource on the regarding form, but this would be quiet ugly, since the data could be edited via n forms from ax.

so is there a way to put the call on the table instead on the forms' datasources?

thanks for hints in advance!

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

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

发布评论

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

评论(2

岁月静好 2024-09-23 17:17:38

AX 数据在 doInsert()/doUpdate()super() 调用时“存储”在数据库中>insert()/update() 方法。

但是,正如 Jay 提到的,这些记录对其他事务不可见(除非您明确允许脏/未提交的选择)。因此它可能对您的存储过程不可见。

无论如何,我不建议在 insert()/update() 中调用存储过程,因为这会影响性能,而且您现在依赖于另一个活动的数据库!

解决方法:

  1. 为此目的将插入/更新记录在单独的表中(考虑使用标准数据库日志记录)。
  2. 从另一个数据库定期监视日志中的新记录(例如每 15 秒一次)。
  3. 根据日志和 AX 表的联接在另一个数据库中执行插入/更新。

日志表布局(数百万之一):

  • LogType - 1=插入、2=更新、3=删除
  • LogStatus - 0=未传输、1=传输中、2=已传输、3=错误???
  • RefRecId - AX 记录的 RecId
  • RefTableId - AX 表的 TableId(如果您需要记录多个表)
  • RefCompanyId - AX 记录的公司(可能该表是虚拟共享的)

建议:

  1. 使用 RecId 作为连接键,并记住启用 RecId AX 表上的索引。
  2. 请记住也选择DATAAREAID(必须以这种方式拼写)。
  3. 在加入之前将 LogStatus 更新为 1,在加入和更新之后将其更新为 2。

The AX data is "stored" in the database at the point of doInsert()/doUpdate() or super() calls in insert()/update() methods.

However, as Jay mentioned, the records will not be visible to other transactions (unless you explicitly allow dirty/uncommitted selects). So it may not be visible to your stored procedure.

I would not recommend calling stored procedures in insert()/update() anyway as this has performance implications, and you are now depending on yet another database being alive!

The way to go:

  1. log insert/update in a separate table for that purpose (consider using standard database logging).
  2. From the other database regularly monitor the log for new records (say every 15 seconds).
  3. Do your insert/update in the other database based on a join of the log and the AX table.

Log table layout (one of millions):

  • LogType - 1=insert, 2=update, 3=delete
  • LogStatus - 0=not transferred, 1=under transfer, 2=transferred, 3=error???
  • RefRecId - RecId of AX record
  • RefTableId - TableId of AX table (if you need to log more than one table)
  • RefCompanyId - Company of AX record (maybe the table is shared virtually)

Recommendations:

  1. Use RecId as the join key and remember to enable RecId index on the AX table.
  2. Remember to select on DATAAREAID (must be spelled this way) as well.
  3. Update the LogStatus to 1 before the join and to 2 after the join and update.
木有鱼丸 2024-09-23 17:17:38

将调用放在 insert() 或 update() 表方法中的 super() 调用之后是执行此操作的正确位置,但是除非您执行未提交的读取,否则存储过程中的 select 语句将不会看到数据,直到之后AX 中的交易已提交。

您能否使用 X++ 中的 ODBC 连接直接写入外部表,而不是通过存储过程间接写入?

Putting the call after the super() call in the insert() or update() table method is the correct place to do that, however unless you do an uncommitted read the select statement in your stored procedure won't see the data until after the transaction in AX is committed.

Could you use the ODBC connection from X++ to write to the external table directly instead of indirectly via a stored procedure?

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