Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Annoying problem with updating data from Input_Boxes

Hi,

I have a quite annoying problem with the updating of data in a "database" (a qvd file). Any help on this would be greatly appreciated.

- In my app, there is basically one Input_box per field where, depending on their privileges, the users can (or cannot) enter data
  => If they cannot or do not enter data, then I want to load from a qvd with the original field_content

  => If they do enter data, then obviously I want to use that to update one record (but only one of course) in the qvd.

- All the variables by default show the current field_content.

- Since I have no other way of recognizing that any field has been edited, the user has to tick a checkbox underneath the field (and
   toggle a variable) so when reloading the script, I have a way of telling whether to use this or that in the LOAD.

In the LOAD (the script is reloaded via a button on the GUI), I have a rather complicated construct:

>> IF($(field1_edited) = 1, IF(rowNo() = $(v_line_ID), '$(edit_field1)', field1), field1) as field1 <<

=> That means, when the variable > field1_edited < has the value 1 (that is the checkbox), then I query the line (the user must choose
     exactly one record for updating) and if that is right, I want to enter the variable > edit_field1 < in the resulting table, otherwise the
     original field_content (that is part of a LOAD from the qvd).

Now, this works fine - if I edit one field and tick its checkbox - and I have that code in place - and select to update the database, the new entry appears.

The issue is, I have 38 fields which means quite a lot of typework in that LOAD. And somehow when I insert that code for every line in the LOAD, at some point something goes wrong and I get a script_error ("error in expression - ')' expected").

I'm afraid I will have to go one line at a time and test it every time.

Can anybody imagine why it works fine at first and at some point it breaks? I do it very carefully to avoid typos - at first I tried building the complete statement in Excel and just copying it, but I abandoned that for the same reason.

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
datanibbler
Champion
Champion
Author

Hi,

I think it's working now.

I discovered some more typos in the underlying short_names of the fields (names without blanks) which are used to generate the variables, so there were some inconsistencies in the variables.

=> As usual, as soon as you do things right, they tend to work ...

Thanks for all the helpful answers!

Best regards,

DataNibbler

View solution in original post

7 Replies
marcus_sommer

Hi DataNibbler,

this could happens if the variables contain not expected values like spaces or NULL or values which will be interpreted as qv statement-parts like comma's or semi-colon's or $-signs and maybe some more. I assume you will need some kind of error-routines before you used the variables directly within your statements.

- Marcus

datanibbler
Champion
Champion
Author

Hi Marcus,

that sounds quite complicated. Thanks for answering!

Well, the variables for the individual fields all mirror the actual field_content - I have renamed all the fields so they don't contain any blanks.

The variables indicating whether a field has been edited can only be 1 or -1.

Of course I will have to inform all the users to observe certain rules when entering data, but that should not be a big problem. Well, I'm afraid I will have to adapt my code line by line.

Best regards,

DataNibbler

ToniKautto
Employee
Employee

From the error it sounds like you have missed a bracket in your expression. I assume you have already confirmed that this is not the case.

Otherwise I would agree with Marcus_Sommer‌‌ that the dollar expansions lead to an incorrect syntax. Check your document log to see exactly what your final expression looks like, and confirm that it looks valid.

datanibbler
Champion
Champion
Author

Hi Toni,

well, that is the problem: When the script_execution fails at some point inside a LOAD, there is no final expression - the full LOAD is in the log and then comes some error_message. It's impossible to tell which line inside the LOAD is wrong.

Anyway, I have found some typos - not in the script, but in the Excel_file where the field_names come for the variables - from there I generate the field_variables. That might also have been the issue.

Let's see.

jonathandienst
Partner - Champion III
Partner - Champion III

If you run the script in the debugger and put a breakpoint on the problem LOAD statement, you can see the statement with all the variable expansions applied. This may help you with finding the problem.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
datanibbler
Champion
Champion
Author

Hi jonathan,

I've read that before, but I haven't yet been able to do it - where exactly do I have to put the Breakpoint to see that? Not on the title for the table, it seems.

datanibbler
Champion
Champion
Author

Hi,

I think it's working now.

I discovered some more typos in the underlying short_names of the fields (names without blanks) which are used to generate the variables, so there were some inconsistencies in the variables.

=> As usual, as soon as you do things right, they tend to work ...

Thanks for all the helpful answers!

Best regards,

DataNibbler