DELETE FOR-PACK ON BUFFERED TABLES

I have a buffered(5-optimistic )tables in vfp 9.0.when i use delete the records arent deleted
i use tableupdate but they dont get deleted.i use pack but i get a msg saying table should be in no buffered mode
i then change buff to 0 (not programmatically with cursorset.. but from dataenviroment)
but is still get the msg!
how can i delete a record table must be in buffered mode


Answer this question

DELETE FOR-PACK ON BUFFERED TABLES

  • innivodave

    i have a grid,and i want when a user presses a button the current record on the grid will be deleted,
    DELETE FROM TempATABLE  
    =TABLEUPDATE(.T.,.T.,"TempATABLE")
    this only marks the record for deletion
    if i put pack i get an error saying table cannot be in buffered mode

  • Dennis Persson

    >> the reason is that with a temp table i can easily create a report and print results the way i want

    But a cursor IS a temporary table. The only difference is that, as Cindy points out, each user has their own copy and it is therefore alwyas used exclusively. YOu can ZAP and re-use it, you can overwrite it with a different structure at any time - you can index it, set relations, run reports against it in fact do just about anything that you can with a normal table - except persist it from one session to the next.

    The key difference is that when the user closes VFP, the cursor is deleted and does not hang around cluttering up disks.


  • srikanthb

    Hi cetinbasoz
    tableupdate doesnt seem to physically delete records in a buffered table,how do i delete them (im talking about old records so tablerevert doesnt help,zap command returns the same as pack.)

  • Chris Kurz

    hi cetin:)thks for the info on delete ill try that.yes im using temp tables and actually im doing what you said in ps.clear table,then select into the table then append to another table,show them in grid,make report of the secdond table etc etc....im about to surrender myself!!!!mercy!

    i prefer tables than cursor because i find them easier to handle,anw ill check that too:)

  • Prabs

    As you have been told several times. TableUpdate() does NOT physically delete records!!! Please stop wasting people's time.

    When you issue DELETE in visual FoxPro it does not physically remove the record from the table, it sets a FLAG on the record. You control whether marked records are visible in an application using the SET DELETED ON/OFF command.

    In order to physically delete records from a table you must PACK the table. To do that you require exclusive use of the table and so such processes are normally handled as Admin tasks.

    When all else has failed, why not read the help file Start with the DELETE command, then PACK.




  • Vasen_c

    Hi Bill,

    I notice that your table is called "Temp..." and that you keep wanting to delete everything and use it again. Have you considered using a cursor It's a temporary table that goes away when you close it or your app closes. Also, each user has his own copy of the cursor so there's no problems with trying to Zap or Pack in shared mode when you want to really get rid of everything. In fact, one way to get rid of everything is to close and recreate the cursor, although you'd need to unset and reset the grid's record source if you did this.

  • Jan Stuchlik

    Then absolutely go with cursors. When you hit something that sounds like you can't do it with a cursor think twice or ask:) For tasks you describe actually a cursor is a much better choice. They're your temporary work "tables" where cleanup is handled by VFP for you.
  • KABay

    Delete from (delete-sql) and delete are not the same commands (and when you say 'delete' people using foxpro for a long time first think of the 'xBase' delete command not the sql one). That explains why you were saying delete behaves like zap.
    delete from myTable
    is equivalant to (except some minor differences that you can read from help):
    select myTable
    delete all

    2nd part:
    select myTable
    delete all
    tableupdate(2,.t.,'myTable')

    PS: Hope you are not deleting all records from a table to use in a grid, using it for some time and then again deleting all, appending from somewhere etc. I'm about to surrender:) 

  • akosonom

    Hello and thank you all for replying,

    Still, I am trying to delete old records from the table.
    My problem here is that the record is marked for deletion but it is not deleted.
    I am using a grid to manipulate the table records.

    I will display my code in order to have a better view of it.

    LOCAL temp
    temp = thisform.txtId.Value

    SET DELETED OFF
    DELETE * from database!myTable;
    where myTable.id == temp
    =TABLEUPDATE(.t.,.t.,'myTable')
    SELECT myTable
    GO RECNO()
    thisform.Refresh


    The table is Optimistic Buffered (Property option No5)

    Best Regards

  • Matt Thubron

    Deleting marks the record as deleted and pack physically removes them. You should think of them as separate things.
    When you delete a record it's marked as deleted and in a buffered table you need to call tableupdate() to persist it. If set deleted is off (set deleted is scoped to current data session and by default off) then records would still show up but with a mark in 'deletemark' column. Set deleted on 'hides' them. If you're using a grid then after a delete operation:
    go recno()
    to force a refresh (normal refresh calls still show the record).
    If you're deleting newly added records in a buffered table then instead you might use tablerevert().
    Pack needs exclusive usage and table should not be buffered. Pack command needs extra care so do not use it till you fully understand in an application (and it's supposed to be in maintanence routines). Alternative 'packing' strategies like selecting those that are not deleted into another table, zapping original and appending back etc are worth to investigate if you would use it.


  • Krzysztof Radzimski

    the reason is that with a temp table i can easily create a report and print results the way i want.

  • Marcelh

    and my second answer plz is how can i delete all records of a buffered table
    thank you in advance for your help

  • cpf

    I thought I already said this. I repeat:
    Delete marks records as 'deleted' (do not physically remove them).
    Pack physically removes records marked as 'deleted'.

    If you delete records in a buffered table but do not call Tableupdate() then records are not marked as 'deleted' (on disk version).
     
    Zap is NOT the same as pack. Zap removes all records physically not just the ones marked as 'deleted'.

  • DELETE FOR-PACK ON BUFFERED TABLES