Values and special characters
Values and special characters
Most important $ codes
Character
Code
Usage
Example
Practical examples
Insert text values into SQL
// Wrong - does not work:
MySQL_Command[0] := 'INSERT INTO users (name) VALUES ('Max')';
// Correct - with $27:
MySQL_Command[0] := 'INSERT INTO users (name) VALUES ($27Max$27)';Dynamic text values
VAR
sName : STRING := 'Max Mustermann';
sCity : STRING := 'Berlin';
END_VAR
// Enclose text with $27
MySQL_Command[0] := 'INSERT INTO users (name, city) VALUES ($27';
MySQL_Command[1] := CONCAT(sName, '$27, $27');
MySQL_Command[2] := CONCAT(sCity, '$27)');
// Result: INSERT INTO users (name, city) VALUES ('Max Mustermann', 'Berlin')WHERE condition with text
Date and time
Numbers do not need $27
NULL values
Reference
Data type -> SQL format
CoDeSys type
SQL format
Example code
Avoid common mistakes
Wrong
Correct
Wrong
Correct
Last updated

