LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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 Kudos
Message 1 of 5
(2,506 Views)

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

0 Kudos
Message 2 of 5
(2,498 Views)

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 Kudos
Message 3 of 5
(2,490 Views)

 


@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 Kudos
Message 4 of 5
(2,484 Views)

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 Kudos
Message 5 of 5
(2,464 Views)