A few days ago I ran into yet another problem with Fox. i have a database where the tables were supposed to be filled with the content of some text files. Those files are dumps of my old dBase tables. I have a routine in Fox code that reads the text file, generates necessary number of records and fills the fields with the content between some delimiters in the text file.
Anyway, it is not the first time I do it with almost the same code. I transferred a dozen tables this way a few months ago, then got distracted by other necessities. I resumed the transfer two weeks ago creating 12 Fox tables and dumping the content of 12 dBase tables into text files. The weird thing is that I could fill only two tables. For the other ten every time I do it if I close the form the records disappear all but the first one. It could be something in the content of my table or what I cannot even begin thinking what it could be. I emptied the tables I filled with no obstacles and refilled them again. I tried many tricks as to have the records stick--nothing helps so far. What shall I try to do about it
Thanks.

records disappear forom tables
shanhuangus
Well, I wish you were right. I am talking to both Cetin and Andy here. I very much appreciate the suggestions.
This issue is so crutial to me, NATURALLY, since it results in such a waste of time that I tried every conceivable variant. As of the last attempt I commented all those statements out
*SET SQLBUFFERING ON
*SET MULTILOCKS ON
cAlias = ALIAS()<statements to fill the table: REPLACE fieldName WITH ...>
*CURSORSETPROP ('Buffering',5,cAlias)
FLUSH
*TABLEUPDATE ()
So, except for the FLUSH everything was removed but I tried it with the TABLEUPDATE as well and with all the other preceeding statements. Regretfully, with the same result.
I noticed this morning that the problem is not confined to one database only. It is more widespread. In other databases it is less egregious. For instance, I just created a table, filled it with the first batch of 800+ records, so far so good. I do not remember if I quit FoxPro or not at that time--it turns out it is essential. Then I began adding records in batches of 10-20. I could see them all when I looked the table up via the recordSource attached to the grid but when I quit foxPro, brought it back up again and checked that table in the database--only ONE record of each batch was still there (the first one). The lesson for me: I have to quit the platform once I added a batch of even 3-5 new records. It creates an increadible HARDSHIP. It is simply outrageous. I do not believe it is something releted to a certain bug or something. Of course, It is possible but the problem is there should be some safeguards agains losing your stuff once it is already there.
OK, I am, of course, looking for the cause of the problem continuously, perhaps I will uncover something. I've never had anything like this even in the Visual dBase!
Yesterday I was able to fill another table in that first database which is filled from text files directly (my old dBase stuff). How come that it works once and then stops working How come it works perhaps once in every 7 attempts There must be someone out there who's had similar experiences. It could not be just my own problem.
Thanks.
bluemaple
Alex,
Just a guess. Buffering is on and no tableupdate() call
GaryWho
ERPLink Chief Technician
>> The lesson for me: I have to quit the platform once I added a batch of even 3-5 new records. It creates an increadible HARDSHIP. It is simply outrageous. I do not believe it is something releted to a certain bug or something. Of course, It is possible but the problem is there should be some safeguards agains losing your stuff once it is already there.
Don't talk complete nonsense! Of course this is not the case - your code is simply wrong and, if you would post it we might be able to help you. This code creates 100000 rows in a table - study the syntax of TableUpdate() and you might understand why you are only ever saving ONE record!
CLOSE ALL
IF FILE( 'testtable.dbf' )
DELETE FILE testtable.dbf
ENDIF
*** Create the table
CREATE TABLE testtable FREE ( ;
iKeyField I, ;
dDateField D, ;
cTextField C(30) )
USE IN testtable
*** Open the table
USE testtable
*** Set it to use Table Buffering
CURSORSETPROP( "Buffering", 5, 'testtable' )
*** Add 100,000 Records
FOR lnCnt = 1 TO 100000
INSERT INTO testtable VALUES( lnCnt, DATE(), "Test Record " + TRANSFORM( lnCnt ))
NEXT
*** Update ALL rows- not just the current row!!!!
IF TABLEUPDATE( 1, .F., 'TestTable' )
MESSAGEBOX( "All Saved OK" )
*** Close the Table
USE IN TESTTABLE
*** Now open it again
USE testtable AGAIN IN 0 ALIAS testtable
BROWSE LAST NOCAPTION
ELSE
MESSAGEBOX( "TableUpdate Failed" )
TABLEREVERT( .T. )
ENDIF
Marcelo del Pozo
Sunder Raman
I appreciate it. I am sorry, but probably, I won't try it. I am not in theoretical exploration to begin with. I prefer to be ignorant. What matters to me is that the trick I found WORKS, or at least it seems to have worked so far.
There are subtle differences between your code and mine. You use INSERT, I use APPEND + REPLACE. I also haven't had problem (AT TIMES!!!!) to fill the first batch of records but then the problems cropped up, etc. I am sure, yours will work but if I go into the comparison deeper I will lose more time. I would better move on.
This is my simple philosophy.
I have more question for your to answer. Just wait another day:)
Thanks a lot.
KAUAIFINN
Cetin, I wish it worked for me but it did not. I do not know why. I wish I could find out. I simply have no time for that.
It is the cruel reality of my life. I respect FoxPro very much and I am fascinated with people who've dedicated their lives to it but I am not a part of this cohort. Sorry. I need it to create a few applications. They are rather complicated but I cannot go any further.
For me TABLEUPDATE() in the loop will work just fine. I do not operate in such quantities as 100,000 records at a time. I am not in production of anything. I add a few hundred records at the most at one time or another. Even 800 records go in in a blink. I can hardly notice. What other costs could be in this for me
Thanks for your comment.
Michal Szalai
Andy hi,
I haven't read your post yet but I've got it under control, finally. It turns out I have to TABLEUPDATE () after every single record that I have appended to the table where the fields were replaced with anything meaningful. In other words the command must be in the FOR .. ENDFOR loop, not after the end of it. Now it works. Still I do not understand why in some cases before I was able to fill hundreds of record in a table, quit and find them there. It is a mystery. Well, at least this problem seems to be behind me.
It is not the way it is done in Visual dBase where one .save() command flushes all changed records to the disk. It never fails. Thus I relied on my prior experience and paid for it. BTW, the FLUSH command does not work (for me, at least) even if it is inside of an iteration loop.
Now I will read your post.
Thanks.
Thomas Sabourin
>> I prefer to be ignorant. What matters to me is that the trick I found WORKS, or at least it seems to have worked so far.
Then you are a fool! I am sorry but anyone who prefers ignorance to knowledge is nothing more, or less.
Your code and your conclusions are wrong. I have given you the correct solution (your use of "TABLEUPDATE()" is incorrect for Table Buffered tables!) but you can't be bothered to look at it.
As the old proverb goes, "You can lead a horse to water, but you cannot make him drink!"
>> This is my simple philosophy.
So you are not seeking help, or understanding, you just want to complain! That's fine, we all know where we stand now.
>> I have more question for your to answer.
Please don't bother asking anything else of me - I have no desire to impose help on those who don't want to be helped. I also have better things to do with my time than waste it on fools.
Chloe
Andy hi,
I do not understand what made you so angry
What is wrong with my code Why cannot I use TABLEUPDATE() after each record is changed
I am not complaining at all just expressing my frustration and I have right to do so. My question is: can you recreate the conditions under which I was losing my records Perhaps there is a structural problem here With your experience you should not have a problem doing it.
If you do not answer my questions, it is fine. I have to move on. Sorry.
jlehew
I'm with Cetin! Check the buffering mode - you almost certainly have buffering enabled but are not calling TableUpdate()
Ales Beranek
Alex,
Calling tableupdate() has a cost. Why would you do it per record in a loop when you can do a single one outside the loop ie:
for ix=1 to 10000
insert into ....
endfor
tableupdate(2, .t., 'aliasHere')