Solved

VFP complains about Cursors in Table Buffering Mode when they're NOT

Posted on 2014-04-16
7
584 Views
Last Modified: 2014-04-26
I have a method which prepares non dbc tables for transactions. Most of the time it works as expected.

I am well aware of the dangers of doing that within transactions or on tables already in table buffering mode. So I test for those conditions before attempting to run the command

Debugging confirms that the Buffering for the relevant table at the point the command is applied is 1 (no buffering)

Despite which it still fails with the error "Command cannot be issued on a table with
cursors in table buffering mode "

I've tried setting the buffering to 3 (optimistic Row) and I've ensure no related table are open in the forbidden mode.

Nada.

Suggestions?
0
Comment
Question by:mjacobs2929
  • 4
  • 3
7 Comments
 
LVL 41

Expert Comment

by:pcelba
Comment Utility
Even the code sample in VFP help shows transaction on a table in buffering mode 5... so your assumption is not correct probably.

To be sure the transaction can start you should work in a "clean environment". It means open all necessary tables, BEGIN TRANSACTION, do all necessary updates, END TRANSACTION, close tables. Nothing else.

Because VFP isn't 100% bug free the transaction started in a middle of some more complex process can fail for whatever reason...

Also remember the fact transaction affects ALL tables and cursors open in the current data session (except free tables) so you should close all other tables or you should check buffering for all other tables if you still think the buffering causes the problem (I also cannot say buffering is OK in all cases)...
0
 

Author Comment

by:mjacobs2929
Comment Utility
thanks for the reply.

It's not my "assumption" - it's VFP's own guidance!

"If row buffering is enabled, then a table update is performed if the free table or free cursor has pending changes before the free table or free cursor is made to support transactions. You cannot use MAKETRANSACTABLE( ) to enable transactions for a free table that has table buffering enabled."

and don't forget, I use this method to PREPARE for transactions, so it's definitely not taking place inside a transaction. (and the first line of the method tests TXNLEVEL() just in case)

However, I think your comments implying  that the state of ALL tables affects the MAKETRANSACTABLE, together with the reminder that VFP isnt 100% bug free, probably brackets the real problem.

I certainly have a number of other tables open whenever I call the method but NONE are in Table Buffering mode.

There must be some rare condition it doesn't like. I'm debugging as we speak and I've just tested my transactions for 4 different processes and they all worked perfectly. It fell over on the fifth with this irritating and, I'm guessing, misleading error message...
0
 
LVL 41

Expert Comment

by:pcelba
Comment Utility
You could implement the transactional processing in a private data session. If you create a Session class which will do the whole process of opening files, making changes, and closing files then your environment should be relatively clean with lower possibility of some mistake.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Accepted Solution

by:
mjacobs2929 earned 0 total points
Comment Utility
Think I've cracked the problem though it isn't a definitive answer. I've found two things relevant. First if you make any table Transactable by default any time you open it, most of the problems disappear.  And, as I've seen no performance hit as a result of defaulting to transactable, you might as well do it for every table you open.  (at least for any table which may be involved in transactions)

Second, even if you do that, I have found one (undocumented - so far as I can tell)  condition (at least) which turns table buffering on, even for non dbc free tables, and that is a freeform browse (as opposed to a properly set up grid). There are a couple of places in my software, where I couldn't be arsed to set up a grid (the user just needs to pick a record from a handful of possibles and I just presented the options as a BROWSE FIELDS NOMODIFY)

As soon as the Browse fires, Table Buffering gets switched on and, of course, if you then try to do anything forbidden in that mode, the error smacks you in the face. The solution (for those who still can't be arsed to run the grid) is to test for the buffering level immediately after the browse and switch it off.

In conclusion:
1 I think pcelba is right to remind us that VFP is not bug free. At the very least, this "table buffering " block is NOT restricted to table buffering (in my tests, the block activates in ANY active buffering mode), and that is a bug by any definition

2 Making tables transactable every time you open them seems to cure 90% of the problem but

3 you still have to watch out for gotchas that can switch on buffering outside your control (eg, at least, free browsing) and either avoid them, or write code that immediately disables the buffering after the (browse).
0
 
LVL 41

Expert Comment

by:pcelba
Comment Utility
Mjacobs, you've investigated the most of your problem here so it is not necessary to divide points etc.

MAKETRANSACTABLE() after the table opening is a good option or it solves some VFP problems at least...

The Buffering property switching is suspicious and I've never seen it before and I am unable to simulate it under simplified conditions on my PC. But it is very good to know about...

Thanks for your input!
0
 

Author Comment

by:mjacobs2929
Comment Utility
just on the question of buffer property switching, I haven't investigated which conditions must be present to cause that behaviour. I suspect it the general networking options (like Set Multilocks On, etc). I might find time, once I've dealt with the present re-coding project, to isolate the exact conditions and post a follow up.
0
 

Author Closing Comment

by:mjacobs2929
Comment Utility
Awkward points allocation problem. I'm happy for pcelba to have the points, or at least half of them for preventing me going down certain blind alleys but obviously he hasn't provided the solution, which is largely spelt out by my last post. Please sort in whatever way is available and acceptable.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now