| |

VerySource

 Forgot password?
 Register
Search
View: 789|Reply: 7

Find one algorithm: quickly change the value of a row in the data table.

[Copy link]

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-21 06:40:01
| Show all posts |Read mode
Known a row, the keywords are DDNO, SEHAO, CHICUN need to determine whether the original record of the row exists in a memory table, if there is a change, if not, add. It is too slow to use the loop directly. Please enlighten me on an excellent algorithm!
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-1-30 14:54:02
| Show all posts
Memory table?

If it is from the database, you can directly use select count (*) from XXX where ............
Then see if the number of rows is 0

If the data is generated during the running of the program, you can consider using hashtable to store and then directly use the key value to match
Reply

Use magic Report

0

Threads

23

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-1-31 13:09:01
| Show all posts
Stored procedure
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

 Author| Post time: 2020-1-31 15:45:02
| Show all posts
The meaning may not be made clear, and the DATASET is now used to operate. Suppose there is a data set ds, there is a table A in ds, there is a row record dr, and the primary key column is a combination of 3 columns "DDNO, SEHAO, CHICUN". Now I want to determine whether dr exists in table A based on the primary key, and update Starting value, if not, add new row to table A
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

 Author| Post time: 2020-1-31 17:18:01
| Show all posts
Because there are too many records in table A, I feel that using the select method and view filtering, or the loop is very slow.
Reply

Use magic Report

0

Threads

52

Posts

34.00

Credits

Newbie

Rank: 1

Credits
34.00

 China

Post time: 2020-1-31 22:36:01
| Show all posts
Create DataView to filter data by RowFilter
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-3 17:15:01
| Show all posts
DataRows [] rows = ds.table [0] .select ("DDNO = 'A' and SEHAO = 'B' and CHICUN = 'C'");
if (rows.length = 1)
{
    Write your logic here
}
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

 Author| Post time: 2020-2-17 20:00:02
| Show all posts
Upstairs, of course, I tried the method you mentioned, and the speed is still not ideal. If you only need to quickly get the value of a certain column and a certain column according to certain conditions, the algorithm should be simpler. How to write such an algorithm?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list