取消
显示结果 
搜索替代 
您的意思是: 

database add row

Hi all,

 

I have a real simple question regarding the database module in LabVIEW.  All I want to do is to find out the max value in column 1, which would be located in the last row of the column, and add another row beneath the last row and have have pervious max + 1 as its value. 

 

 

How do you do this with the two approaches below?

Approach 1.

1. move the cursor to the last row.

2. read the last row and get its max

3. add a new row below the previous last row with new max.

 

Approach 2.

1. Do SQL query to get the max on column 1

2. add a new row below the previous last row with new max.

 

Thanks!

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 项奖励
1 条消息(共 5 条)
3,275 次查看

I would do option 2. It's just a SELECT MAX(column_name) statement.

0 项奖励
2 条消息(共 5 条)
3,267 次查看

Are you familiar database design choices such as AUTO_INCREMENT in a column definition in SQL? The reason I ask this is because the question you asked might have a more elegant, safer, and easier solution than the path you're currently taking.

0 项奖励
3 条消息(共 5 条)
3,259 次查看

 


@jyang72211 wrote:

I have a real simple question regarding the database module in LabVIEW.  All I want to do is to find out the max value in column 1, which would be located in the last row of the column, and add another row beneath the last row and have have pervious max + 1 as its value.


That's something you can never really be certain of when it comes to databases, it's also not an issue. In which order the database stores data is completely irrelevant, if you need it in any particular order you use 'Order by'. 🙂

 

As for the solution, i'd also go for version 2, unless you can change the database to autoincrement, as mentioned.

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
4 条消息(共 5 条)
3,253 次查看

I am only used to querying data from a database, but I am not used to setting up database or adding things into database.  Thank you!  I will try option two.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 项奖励
5 条消息(共 5 条)
3,233 次查看