Foxpro 7 测试“文件正在使用”插入之前

发布于 2024-11-28 01:26:58 字数 298 浏览 3 评论 0原文

我有一个 VFP TABLEUPDATE() 函数的包装器,该函数除其他外,还记录对其他表所做的添加和更改。由于多个用户在整个应用程序中进行保存和编辑,日志表有时会受到影响,这会导致我的日志表上出现“文件正在使用”错误。调用 INSERT 时表未打开。

我有理由确信没有进程以独占方式打开该文件。理想情况下,我想

  • 检查并查看该文件是否可打开
  • 使用 INSERT INTO 写入文件
  • 尽快退出

记录永远不会被编辑,只会被插入。有没有办法可以在发出 INSERT 之前测试表?

I have a wrapper to the VFP TABLEUPDATE() function which, among other things, logs additions and changes to other tables that are made. The log table gets thrashed on occasion, due to multiple users saving and editing throughout the app, which results in a 'File is in use' error on my log table. The table is not open when the INSERT is called.

I am reasonably sure no process has the file opened exclusively. Ideally, I want to

  • Check and see if the file is available to open
  • Write to the file using INSERT INTO
  • Get out as fast as I can

Records are never edited, only INSERTed. Is there a way I can test the table before issuing the INSERT?

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

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

发布评论

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

评论(3

小瓶盖 2024-12-05 01:26:59

我的第一个想法是,您将桌子打开的时间太长,并且您添加的任何初步检查只会使桌子保持更长时间。 INSERT 后是否关闭表?

您说日志表在进程开始时未打开。这意味着 Fox 会默默地为您打开表,以便 SQL 可以运行。您是否以独占方式打开它,然后是否明确关闭它?

My first thought is that you're holding the table open for too long and that any preliminary checks that you add will just tie the table up for longer. Do you close the table after your INSERT?

You say that the log table isn't open at the start of the process. This means that Fox will open the table for you silently so that the SQL can run. Are you opening it exclusive and are you explicitly closing it afterwards?

时常饿 2024-12-05 01:26:59

您是否尝试过在插入例程中锁定表?

IF FLOCK("mytable")
   INSERT INTO ......
ELSE
  WAIT WINDOW "Unable to lock"
ENDIF

也许将其放入 DO WHJILE 循环中?

Have you tried locking the table in your insert routine?

IF FLOCK("mytable")
   INSERT INTO ......
ELSE
  WAIT WINDOW "Unable to lock"
ENDIF

Perhaps put this into a DO WHJILE loop?

给妤﹃绝世温柔 2024-12-05 01:26:58

如果您收到“文件正在使用中”(错误 3),则根据 Visual Fox 手册:您已尝试对当前打开的文件执行 USE、DELETE 或 RENAME 命令。所以你说删除或重命名是不可能的。
它必须是 USE IN SELECT("cTableName")。
如果 EXCLUSIVE 为 OFF,则无需检查文件是否打开。
INSERT 之前不要打开表。只需执行 INSERT 即可,之后无需关闭表。
因此,您可以摆脱 UNLOCK IN cTableName USE IN SELECT("cTableName")。

If you receive File is in use (Error 3), then according to Visual Fox Manual: You have attempted a USE, DELETE, or RENAME command on a file that is currently open. So you say DELETE or RENAME is out of the question.
It must be the USE IN SELECT("cTableName").
If EXCLUSIVE is OFF, there is no need to check if the file is open.
Do not open the table before INSERT. Just execute the INSERT and there will be no need to close the table afterwards.
And so you can get rid of the UNLOCK IN cTableName USE IN SELECT("cTableName").

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