PLCSQL Link - Support and Download
Back

How do i denormalize the normalized log and recipe data to get them in a regular table?

You can use the SQL Stored Procedure sp_SaveParams, which is included in the sample PLCSQL Link database:

Here is an example:

CaLL sp_SaveParams
 @UserID = 1,
 @TablePrefix = 'Recipe',
 @tstring = '1;2.345; 10002;1234; 15002;1234567; 20001;1; 20002;0; 30002;Recipe 1;

You should modify the @tstring variable to your needs. Is is a paired semicolon separated string containing respectively the Parameter ID as it will appear in the PLC and then the value to be saved.

The values in the example can be used in the demo project and is:

ParamID      Value        Type     Description
1            2.345        REAL     Command Level
10002        2            INT      Actual recipe number
15002        1234567      DINT     Large number (not used in demo). -2147483648 to +2147483647 
20001        1            BOOL     1=Start heating
20002        0            BOOL     Add soap. 1=Yes, 0=No soap.
30002        'Recipe 1'   STRING   Recipe name

To insert 3 recipes for testing in the database, you could use the following example:

CALL sp_SaveParams (1,'Recipe','1;2.345; 10002;1; 15002;1234567; 20001;1; 20002;0; 30002;Recipe 1; 30003;HelloWorld 1');

CALL sp_SaveParams (1,'Recipe','1;7.442; 10002;2; 15002;-4548741; 20001;0; 20002;1; 30002;Recipe 2; 30003;HelloWorld 2');

CALL sp_SaveParams (1,'Recipe','1;4.23; 10002;3; 15002;0; 20001;1; 20002;1; 30002;Recipe 3; 30003;HelloWorld 3');

Please note, that you must choose Parameter IDs inside the correct range:

1-9999         REAL   (Default range: 1-50)
10001-14999    INT    (Default range: 10001-10050)
15001-19999    DINT   (Default range: 15001-15050)
20001-29999    BOOL   (Default range: 20001-20050)
30001-39999    STRING (Default range: 30001-30009)

Please note as well, that the size of the arrays in the SQL_Recipe DB in the PLC must be adjusted, if you want to go outside the default range.

The range is rather limited as default, to avoid filling up the PLC memory with unnessesary data in smaller applications.

The PLCSQL Link will give an alarm of invalid ParamID when receiving the recipe if you don't adhere to this.


ALSMATIK A/S | Lollandsgade 2 | DK-6400 Sønderborg | Denmark | Tel.: +45 74 43 46 84 | www.alsmatik.dk