omron — Controller NX NJ MySQL SQL 2.0 Quick Start EN 202002 SW 103 (EN)

We will now perform a simple insert command to make sure the SQL functionality is working properly. Create the mapping. The mapping is used to create the SQL query string that is used internally. Create a custom structure that matches the table’s columns exactly (case sensitive). Select the correct data type for each member. If you’re using a string, add 1 additional character to the string length (the variable “Name” size was set to 10 in MySQL). Create a variable of the newly created structure. Set the variable as the MapVar input of the function block. Set the SQLType to the type of SQL command that will run on this variable. In this example, set it to “_DBC_SQLTYPE_INSERT”.

Set the TableName to “myTable” or the name of the table you want to insert the data into. Note: NJ allows 60 mapped variables whereas the NX1 allows 30. Note: You cannot use the same mapped variable for INSERT, UPDATE and SELECT. The map variables must be unique. Add the Name and Value that will be inserted to the DB (Ex. Bob and 11). Note: The member ID is not used because it was set to automatically incremented on every insert.