Need to load records from SQL into tags in PLC

I have a table in SQL that I would like to download into an array of tags in my PLC (via OPC server, of course). The table contains employee information and all I need is the employee name and corresponding employeeID. I have tags set up in the OPC server to handle up to 60 employees. So the query can contain up to 60 records of 2 fields each and then FSQL will transfer the results to the OPC tags.

I’ve tried using a stored procedure group object but that doesn’t seem to work unless I provide 120 output parameters.

I’m looking at the block group object but I can’t quite figure out how to make it work.

So, all in all, I’m looking for the best way to collect a variable, but limited, quantity of records and transfer them to my PLC.

A block group sounds perfect for what you need to do. In your case, the block group will grab 2 columns (OperatorID and OperatorName) for each of 60 rows of data from the specified table and pass them down to the addresses you entered. You can set up the OPC addresses either by entering them manually, or by using ranges.

What exactly is happening when you try to start the group?

I get the errors show below.

The thing is, when I check my OPC server I see a bunch of errors in the event log stating:
“Attempt to add item ‘’ failed.”, where is all the tags I wanted FSQL to write to (AvailOpIDList0, AvailOpNameList0, etc). I didn’t want to ‘add’ them since they already exist in the OPC server.

I know the OPC tags work because I can access the PLC data in another client.

But I guess my other question is how can I set up the Block Group for a variable amount of records. Right now I have 60 records in the query because I have 60 tags in the PLC. 60 is the maximum limit. But depending on Operator Availability the query may return 5, 20, 35, or even 60 records.

When I start the group with less than 60 records in the query, I get the error: “This group requires 60 rows, but there are currently only 59. Would you like to add the remaining rows now?” If I say ‘Yes’, I get an error trying to insert a Null into a non-nullable field. If I say ‘No’ then the group starts but then fails as stated earlier.

So if the Bock Group is expecting 60 but I let it run with 59 or less, do the remaining rows pass Null values? (This is what I would like it to do but seeing as I haven’t gotten past the other errors I don’t know what will happen.)

‘error trying to insert a Null into a non-nullable field’ means that one or more of the columns in your destination table aren’t being written to but cannot contain null values. You can modify the table to accept null values in all the fields so you have no problem starting the group (if you choose to add the 60th row).

Each block group must have a static number of OPC items, you can’t change them on the fly. But you can make sure all the extra rows in the database contain some known bad value that the PLC will discard. When you say ‘the query may return 5, 20, 35, or even 60 records’, what query are you talking about?

As for the picture above, it looks like your tags aren’t subscribed properly. Can you bring just one into a group and see if it shows you a good value?