How do I create new recipe data in the SQL Server?

150 views
Skip to first unread message

Anders Jorsal

unread,
Apr 4, 2013, 5:04:12 PM4/4/13
to plcsq...@googlegroups.com
You can use the SQL Stored Procedure sp_SaveParams, which is included in the sample PLCSQL Link database:

Here is an example:

EXEC sp_SaveParams
 @UserID = 1,
 @TablePrefix = N'Recipe',
 @tstring = N'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 seperated 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 recipies for testing in the database, you could use the following example:
EXEC sp_SaveParams 1, N'Recipe',N'1;2.345; 10002;1; 15002;1234567; 20001;1; 20002;0; 30002;Recipe 1; 30003;HelloWorld'
EXEC sp_SaveParams 1, N'Recipe',N'1;7.442; 10002;2; 15002;-4548741; 20001;0; 20002;1; 30002;Recipe 2; 30003;HelloWorld'
EXEC sp_SaveParams 1, N'Recipe',N'1;4.23; 10002;3; 15002;0; 20001;1; 20002;1; 30002;Recipe 3; 30003;HelloWorld'


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 unnessecary 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.
Reply all
Reply to author
Forward
0 new messages