LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Systematic and best way to update database

Hi all

 

I am having a confusion regarding how to update a database with reference to system performance and overal efficiency.

Actual Situation:

There is a Testplace which performs a number of tests and logs the results to a tab seperated text file. e.g Teststep 1 give result Voltage = 15V ,Teststep 21 give result Current = 2A and so on.( around 10 teststeps) and overall there are 5 Testplaces with each having a different name.

I am now planning to  insert the measured values from all testequipments to a database using database toolkit. 

 

Option 1: to use hardcoded queries to insert values to DB. eg. INSERT INTO Testplace1 (Voltage,Current) Values (15,2).

i.e to get measured values from teststeps and to concatenate them to query statements and run it.

The problem with this is: if some columns have to be deleted/inserted in the future, then i have to change every where in the program where it is hardcoded.

 

Is there a better way to insert values into DB rather than hardcoded queries?

Thanks in advance

 

Nghtcrwlr

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 1 of 4
(2,404 Views)

Stored procedures (SP) are stored inside the database, rather than in your code.  However, if you are changing the number of columns, you will most likely have to change the code anyways in order to pass the additional data to the SP.    I still prefer them over hard-coded queries because once you have code in place, it's easy to call a different SP by passing in the SP name and the appropriate data. 

aputman
0 Kudos
Message 2 of 4
(2,381 Views)

@Nghtcrwlr wrote:

The problem with this is: if some columns have to be deleted/inserted in the future, then i have to change every where in the program where it is hardcoded.


You'd make a subVI, and use that everywhere in your code. If the table changes, you only have to change the subVI...

 

You can put complex queries in SP, and that is highly recommended. Simple inserts can't be avoided, with a SP you still end up with a query.

Message 3 of 4
(2,332 Views)

Thank you guys... Stored Procedures are quite new to me. I will go through a tutorial and try to implement SPs.

 

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 4
(2,312 Views)