Finding and updating

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
Hi, I know how to use the .find method to locate and update a record using the tables primary key.

I know how to find rows using the .select method, but can't see how to upade the returned row(s)

If I assign the returned rows to a row array then these are copies of the original rows which I dont know how to update rather than add??

Any pointeres please?
 
I need to search the datatable for a row by a field that is not the priamry key.

\i can find it using the .select method but this returns a row object so I then need to change this row accordingly and write it back to the datatable.

When I search using the primary key using find method I can locate and update in one.

But the select way which I also need to doI cannot see how to udate the row in the datatable.
 
But the select way which I also need to doI cannot see how to udate the row in the datatable.

Select the row.. you then have the row, you can then get the primary key of the row, you can then Find the row...

Also, look at datatable.merge
 
I actually thought of that, ie use select to get the row inquestion then using the primary key from this use the .find method to find the row to edit, but thought this was inefficient as it was doing two searches?
 
However you cut it, including use of Merge, will involve a PK based search to find the row. Find() is hashed and is or near O(1), Select() is iterative and is hence O(n). In a table of 1000 rows, select may/will take up to a thousand times longer than Find

Dont worry about it
 
Back
Top