which is safer to use table or view?

Opening a native table is very vulnirable to sudden power failure. So which is safer of the two; Using directly the table or make a view of that certain table before using it




Answer this question

which is safer to use table or view?

  • Sajaki

    A view would theoreticlly be safer as it is a SQL query to the data. But why are you having this problem

    In 20 years of working with DBFs I only had this happen to me once, many years ago.

    There is only one reason not to have an Uninterrupible Power Supply (UPS) unit on each PC, server, router.

    The only reason not to have one is when the value of the data or the cost of re-building the data is less that the cost of the UPS. How often does this happen How many hours a week/month/whatever do you lose rebuilding/re-entering lost data There's your simple math to compare the cost and tell your boss to buy a UPS. :)

  • Crosscourt

    There are a couple of things you can do to make the system more stable:

    - The program should make backup. I don't how about how much data we talk here, but the application should make a copy of all tables when it starts, work on the copy and copy them back when it shuts down. If you rename the original files before you copy the working copy of the real data, you can even catch the case that the application crashes in the middle of a shut down.

    - Don't keep the tables open. It slows down the program a bit, but try to keep all tables closed. Only open them as needed. Opening a view opens the table.However, you can close it right afterwards. When VFP updates the view into the table, it opens the table itself again.

    - Do not perform batch updates. Update one record (or one set of related records), close the table, open it, update the next record.

    - Do not rely on your customer to do maintenance tasks. Your system should do all the backups automatically.


  • juanazo

    We are in a 3rd world country and I forgot to mention the worst case scenario. I am figuring-out what if the UPS will bug-down at night and you have to continue your work, so you have no other choice but to connect your PC directly to the wall outlet. Then here comes the sudden power failure. So what will happen next Your work will be of waste and there you have to reconstruct your work again. So that is why I am asking which is much safer to use.

    Here's also another question, Has any idea why VFP did not include a recovery tools for there native dbf or I only miss that topic in help file,  Why is it that we have to look for a third party tools for a dbf recovery

  • Scott Ha

    I feel for you, I have a similar problem but on a larger scale.  I design racing software that is used on about 5000 customer computers at racetracks all around the world.  They run on generators which are always shutting down.

    Since I cannot control the generators I make sure I have NO INDEXES kept open, I also delete tag all after every report, and I delete each index file before reindexing. 

    I still get a problem every couple of months but my solution is to create backups of the critical data every few minutes.  If the error handler reports one of the error numbers that relate to indexes or corruption then I copy the backup over and continue.

    Good Luck.

    Don Higgins
    www.crewchiefpro.com



  • WinL

    Don't forget that whenever you open a view, VFP also opens the table, because a view is just a SQL SELECT statement that "lives" in a .DBC.

    So from a corruption-due-to-power-failure standpoint, there isn't really any difference because you cannot have a view open without the table being open.  Even if you could, you wouldn't want to open the table just long enough to post changes in the view into the table, and then close the table again.

    So I agree with Alex -- you need to resolve your power supply issue.

    Drew Speedie
    VFP MVP

  • anametrix

    Thank you Don, that's what I am doing.

    No matter how you explain that to your client but sometimes when things go right for months, a year,  they will forgot to do routine maintenance to their system.

    So there comes an unexpected call, telling you that their system doesn't work anymore due to corruption.  I will then instruct them to reinstall their backup, the answer is this 'OHH NO... we don't backup our data's for a month now... see..

    I dO not use native dbf for my FP application, I use MS SQLServer since the release OF VFP6, but I have a customer that has a know-how about programming in FP, that is why he doesn't like other back-end, for some reason I do not know.

    So problem isn't it

  • Kallex

         I do that before.  The applic. will automatically backups all critical datas. But the PC will gone crazy if at the the time of back-ups there was an incoming entry of the user. (most common occurence is that it HANGS-UP)

        Anyway, thank you very much to all of you, at least I got another idea what to do next.

       Have a nice day & more power to all of you...

  • which is safer to use table or view?