1 Reply Latest reply on Jan 3, 2010 6:37 PM by zx81

    script execution

    zx81

      Title

      script execution

      Post

      Hi

       

      Could someone please just confirm if the Filemaker script engine waits until a previous command has executed before running the next command?

       

      I'm using Filemaker to update records in a MySQL database on a web server, and before running the ExecuteSQL command, I merge fields in Filemaker which is then critical for the web app. This works fine in 99 times out 100, but the 100th time results in disaster (i.e loss of info in all records in MySQL database).

       

      The main script is like this:

       

      Go to Record/Request/Page [First]

      Loop

        Perform Script ["Update"]

        Go to Record/Request/Page [Next; Exit after last]

      End Loop 

       

      The Update script is as follows (a few more Execute SQL lines in the actual script):

       

      Perform script ["merge"]

      Execute SQL [No dialog; DSN; g2; Calculated SQL Text: Evaluate(products::sqlUpdateCheckoutProduct)]

      Execute SQL [No dialog; DSN; g2; Calculated SQL Text: Evaluate(products::sqlUpdateCustomCheckoutPricing)]

       

      Now, what I need to know for sure is that the 'Perform script' line is finished before the Execute SQL lines are run.

       

      Is such a control default or not? If not, can I implement it somehow?

       

      The reason I ask is that the error I get is that the sql field updated but the second Execute SQL line, indicates that the merge is not done; i.e instead of containing something like product_id:1000, it just contains :1000. However, when I check in Filemaker, the target field used by the Set Field command, contains the merged info. 

       

      At two different times, this has caused a severe error where I have to manually fix it for all records which is not very funny.

       

      I've been using Filemaker now and then for approx 20 years, and MySQL now and then, but this is the only integration I've done.

       

      The database runs locally, I just use an ODBC connection to Execute SQL 

       

      /zx81 

        • 1. Re: script execution
          zx81
            

          nevermind, I found the cause: the Filemaker database (made by my client) had some records with empty product ID fields. My SQL script used the WHERE ... LIKE syntax and an empty product ID string followed by a % in the SQL query matches everything, which explains why all records were affected.

           

          sorry for taking your time with this

           

          /zx81