0

又是一个 axapta 问题(在 ax 2009 和 sql-server 2008 r2 上运行):这正是插入或更新的数据集存储在相关数据库中的时间点?

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

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

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

感谢您提前提示!

4

2 回答 2

1

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.
于 2010-09-02T10:57:43.227 回答
0

在 insert() 或 update() 表方法中的 super() 调用之后进行调用是正确的方法,但是除非您执行未提交的读取,否则存储过程中的 select 语句将在之后才能看到数据AX 中的事务已提交。

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

于 2010-09-01T15:58:30.853 回答