07-26-2010 02:50 PM
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
07-26-2010 03:23 PM
I would do option 2. It's just a SELECT MAX(column_name) statement.
07-26-2010 07:11 PM
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.
07-26-2010 08:36 PM
@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
07-27-2010 10:30 AM
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