Hello friends,
Im trying to send some data to a DataBase but the problem is that when the data is inserted it is savig 3 times the same information
Ok, this is what I have,
In a Vision Window I Have 2 calendar boxes, one with the current time and the other one fixed
The left box called time0 has this code in the Expression area: now()
The box on the right, called time1 has this code: dateArithmetic(dateFormat({Root Container.time0.date},"yyyy-MM-dd HH:mm:00"),1,'sec')
I did this because I need that each minute both date must be the same and when this happen some information must be inserted to the data base
I have this code in the propertyChange of the time0 button (because it change each second so it can check each second if both dates are the same):
time0 = event.source.text
time1 = event.source.parent.getComponent('time1').text
value = event.source.parent.getComponent('LED Display').value
flowmeter = event.source.parent.getComponent('flowmeter').text
parameters = {"date":time1, "value":value,"flowmeter":flowmeter}
if time0 == time1:
system.db.runNamedQuery("Insert Data", parameters)
The Named Query is this
INSERT INTO _mydb
( date_, meter_, volume_)
VALUES
(:date , :flowmeter , :value )
But this is inserting in the database the same data 3 times
So, I tried with a while statement trying to run just one time the query
if time0 == time1:
i=0
while i<1:
system.db.runNamedQuery("Insert Data", parameters)
i+=1
With the same results so that tell me that the script is running 3 times at the same time and no just one time.
So if you have some ideas I really appreciate that.
Thank you!