Skip to main content
14-Alexandrite
February 14, 2024
Solved

Remove row from C SDK edge infotable

  • February 14, 2024
  • 1 reply
  • 1470 views

Hello,

 

Is there a method to delete a row from infotable 'twInfoTable' on C SDK.

I am able to add row twInfoTable_AddRow, also update specific entry in row using 'twList_ReplaceValue'

But couldn't delete a row.

I tried this example after add 3 rows in my example datatable  (the second row exist 😞

twInfoTable* it = TW_GET_PROPERTY(DEFAULT_THING_NAME, "Inventory").infotable;
twInfoTableRow* it_row = twInfoTable_GetEntry(it, 1);
twInfoTableRow_Delete(it_row);
TW_SET_PROPERTY(DEFAULT_THING_NAME, "Inventory", twPrimitive_CreateFromInfoTable(it));

 I have a classic c error :Segmentation fault (core dumped) at the last line of code.

Thank you for your help.

Best answer by AliBenBelgacem

I find out the solution and it's very simple

we can use twList_Remove(..) to remove a row from an infotable

After all infotable its a list of rows so we can use directly twList_Remove(infotable->rows, rowToDelete, TRUE)

 

1 reply

Rocko
19-Tanzanite
February 15, 2024

My C days are long gone, but you haven't checked it_row for null, are you sure it's not null?

14-Alexandrite
February 15, 2024

Already checked 

Rocko
19-Tanzanite
February 15, 2024

I am by no way an expert on this, but I recommend creating a ticket with Support. To me it looks like twInfoTableRow_Delete just frees the memory but does not remove the row from the infotable. The workaround would be to copy over the rows you want to keep to a new infotable.