SQL and PMI questions

Ok let me simplify things a bit.

  1. In FSQL I do have the where condition set up. SO that is correct. I used the same type of scenario as shown in the Quick start video.

However as I mentioned when a connection is lost KepServer reports back the word NULL in each of the fields, not 0 (zero), it reports back the word NULL. When it does this something weird usually happens. And that weird thing is I get error messages becuase it wrote the word NULL under the machine ID number. SO now each time this group trys to run and references the key of machine ID you software throws and error message. Why, because the machine number has been over written and is now a NULL and it can not find that keyed number. Then when the machine comes back online and starts reporting information back it adds in a new row of information. Why? Because there is currently not a 26 or whatever number I am using in the database.

An idea I came up with would be make a database thru SQL not thru FSQL dont address the machine ID number in any of the FSQL fields. That way maybe the machine number will remain static and unchanged. What do you think?

[quote=“nathan”]I think your FactorySQL group setup can probably be simplified. You should be able to take a machine down without creating problems. To address your questions:

  1. Make sure that the group isn’t set to “Insert new record” - that’s how you set up historical data logging. You should set it to “update/select custom record” then in the WHERE field type your condition. Keep in mind that this condition applies with respect to the database. You do not need Kepware/PLC values to make this work. The FactorySQL group “knows” which machine you’re referring to by OPC tag paths. It determines which database row belongs to it with the WHERE clause.

  2. I think that Kepware is behaving properly by reporting NULL values when a machine is taken offline. You will see a different value in the “OPC Quality Code”. Check “store OPC Quality code” in the group property. Then use that value in FactoryPMI to show the user that the machine is down and disable it.

  3. I don’t know how FactorySQL could be adding to the database instead of updating it based on NULL values. Groups strictly either keep INSERTING records or UPDATING the same one, based on that group property. If the value is NULL it will write that in either case.[/quote]