Why the last line of the script does not execute?

Hi All
I have a script behind the action performed event handler which is triggered by the button.
In the script there is a call to the function in the project module.
In the function there is system.db.runQuery(SQL), where SQL is a list of statements to reset some data in the database.

The last command in the function after system.db.runQuery(SQL) is command system.tag.write(tagpath, not tagvalue) to toggle a value after reset it does not execute.

What is strange:
If the last toggle command is placed inside the function after system.db.runQuery(SQL) it does not execute at all without any error (although i am questioning my sanity as i think i saw some error just once).
But if above command is placed outside the function but inside the script behind the button it does execute properly and reliably every time.

Does anybody know what might be the reason?
I don’t see any error now but is this possible that sometimes errors are somehow supressed and stop displaying?

Are you sure your SQL is ok? JDBC doesn’t specifically allow multiple statements or comments, though some branded JDBC drivers do.

1 Like

The best we can help is if you show your script, formated by pressing </>

1 Like

Wow that’s spot on suggestion. I am using mariadb jdbc driver and i use multiple delete data statements inside the function behind the button:
SQL =
“”"
BEGIN
DELETE
FROM Table1
DELETE
FROM Table2

END
“”"
1 do you know where can i find more info about maria jdbc driver. It seems to work at the moment but i need to test it more
2 do you think if using BEGIN and END statements in the SQL command make any difference or is it just block of code to be executed?

As a test i did commend out system.db.runQuery(SQL), saved the change and refreshed and the toggle command still did not work.

Below is the code behind the button which opens a popup which then triggers a function

thanks for reply please my reply to Phil’s comment

i did not know about code formatting feature -thanks

you say thanks but did not use it xd

2 Likes

In this case I don’t see why you can’t just run two system.db.runUpdateQuery statements one for each table.

If there’s more logic to it you’re not showing to use and want to make it done in a single database call, you can always make it a stored procedure and call that.

If the concern is that you want to avoid the situation where DELETE FROM table1 one runs but DELETE FROM table2 does not, I would suggest using database transactions.

1 Like

i read your comment after pasting the code
i will use it from now on :slight_smile:

i totally agree i should run a transaction because if one command fails due to some foreign keys issue the whole reset would be dangerous and should be reverted.