gpt4 book ai didi

ms-access - 为什么使用 postgresql odbc 驱动程序 Access 2010 会调用 IDENT_CURRENT?

转载 作者:行者123 更新时间:2023-11-29 12:22:49 26 4
gpt4 key购买 nike

我正在将 access 2003 应用程序迁移到 access 2010。该应用程序使用 postgres odbc 驱动程序来 Access 其数据。

在 Access 2010 时,它尝试在 postgresql 服务器上使用 IDENT_CURRENT 函数(如使用 wireshark 所见)来识别最近插入的行的 id ...不幸的是,据我所知,IDENT_CURRENT 不是 postgresql 支持的函数。 ..

我正在使用最新的 postgresql ODBC 驱动程序 (9.0) 和 postgresql 8.3 数据库。

最佳答案

使用 currval是正确的方法(强调我的):

Return the value most recently obtained by nextval for this sequence in the current session. (An error is reported if nextval has never been called for this sequence in this session.) Because this is returning a session-local value, it gives a predictable answer whether or not other sessions have executed nextval since the current session did.

将其包装在 IDENT_CURRENT 函数中是一种非常合理的移植技术。

你也可以使用 RETURNING id在你的 INSERT 语句上(再次强调我的):

The optional RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted. This is primarily useful for obtaining values that were supplied by defaults, such as a serial sequence number.

这可能会更快更简洁一些,但您仍然会遇到一些可移植性问题。 OTOH,我认为无论您做什么,都会遇到可移植性问题。

关于ms-access - 为什么使用 postgresql odbc 驱动程序 Access 2010 会调用 IDENT_CURRENT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5552956/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com