EMPTY TEMP-TABLE

Posted by Roger Blanchard on 18-Jun-2014 07:00

Is there a way to empty the TT on the client side? Something similar to EMPTY TEMP-TABLE ttCustomer.

All Replies

Posted by agent_008_nl on 18-Jun-2014 07:04

What's your exact problem, can't you use EMPTY TEMP-TABLE ttCustomer? Maybe you can use the method?

EMPTY-TEMP-TABLE( ) method

Deletes all records from a temp-table associated with a buffer object.

When you empty a temp-table that is defined as UNDO within a transaction, the ABL Virtual Machine (AVM) deletes the records individually. This is less efficient than emptying the temp-table outside the transaction, where the AVM deletes all records in the temp-table as a unit.

Return type:  LOGICAL

Applies to:  Buffer object handle

Posted by agent_008_nl on 18-Jun-2014 07:05

Ah, sorry, group = mobile. Don't know about that.

Posted by Roger Blanchard on 18-Jun-2014 07:07

I should have specified on the mobile device.

Thanks

Posted by Peter Judge on 18-Jun-2014 07:48

Roger,

You can loop through the records and remove them as follows:

 // remove cart options, if any exist
VehicleOrderService_ShoppingCartService_JSDO.jsdo
  .eShoppingCartOption
  .foreach(function(cartOption) {
    // console.log(cartOption);
    cartOption.remove();
});


Posted by Roger Blanchard on 18-Jun-2014 07:59

Thanks Peter.

Posted by egarcia on 18-Jun-2014 08:21

Hello Roger,

You could use the addRecords() method by adding no records using the EMPTY mode.

Examples:

- jsdo.eCustomer.addRecords({}, progress.data.JSDO.MODE_EMPTY)

- jsdo.addRecords({}, progress.data.JSDO.MODE_EMPTY)

The addRecords() method is valid at the jsdo instance if there is only one temp-table.

The difference between this approach and using the remove() method is that remove() marks the record to be deleted in the JSDO and if you call saveChanges() a DELETE operation would be sent to the backend.

I hope this helps.

This thread is closed