Storing data from SQL into Tags

Hi,

I have about 100 meters, that are saving the demand kWh into an SQL database which is updated is every 15 mins, now I want to take these data and store them in tags as if I am reading it directly from the meters and then manipulate the actions of graphic elements using the values I am getting.

The issue for me is that my knowledge in SQL is limited, and also I know it has to be done via cicode, I was successful into connecting to the database, and using "Database Exchange Control" to show the data I want, but sadly that is not what I want, again I want to store them periodicity in the tags, to be able also to have alarms, trends for these meters.

  • Hello

    Yes Database Exchange Control would not be appropriate for this use case. You are right you have to use Cicode for establishing your connection and querying the data you need and saving it to the tags and you can have this done periodically using Citect Reports. Have a read in the help "Cicode Programming Reference > Cicode Function Categories > SQL Functions". Without knowing how your data is setup in your database this could be one SQL query or multiple. I would recommend you have a structured tag naming conventions and use arrays in your Cicode for the writing to tags to make it even easier.

    Just another question, is there a particular reason why Citect is not talking directly with the meters and you can get rid of the middleman?
  • Hi Richard,

    So the meters are using a protocol called DLMS/COSEM (IEC 62056) which is the first time for me to see it, I looked around and couldn't find a driver for it, so I assumed that I cannot communicate with it. The meters themselves are part of a system solution called SEP2W System MDM, where they are sending the data via 3G to this system, and in the end it is being stored into an SQL database.

    When I found out that this unknown system (for me) is storing the data in the end into SQL, I thought it would be better to at least try working in the SQL path, where I know Citect was already being used before.

    The thing now is I am the kind of person who would need a sample of a code to start building my own, so are there any sample project where the Cicode for the query and then storing is being done, to be honest I am struggling a bit with the help now in the SQL part, as I already have the backup of the database, and also the query the customer is using to fetch his data in the end in the table he wants, I think it is doable (at least in my opinion)