1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-25 22:12:29 +02:00
Files
OpenIntegrations/docs/en/examples/MySQL/ExecuteSQLQuery.txt

60 lines
2.2 KiB
Plaintext
Raw Normal View History

2025-06-27 11:47:43 +03:00
 Image = FunctionParameters["Picture"];
2025-03-27 20:05:59 +03:00
OPI_TypeConversion.GetBinaryData(Image); // Image - Type: BinaryData
2025-06-27 11:47:43 +03:00
Address = FunctionParameters["PG_IP"];
2025-03-27 20:05:59 +03:00
Login = "bayselonarrend";
2025-06-27 11:47:43 +03:00
Password = FunctionParameters["PG_Password"];
2025-03-27 20:05:59 +03:00
Base = "test_data";
ConnectionString = OPI_MySQL.GenerateConnectionString(Address, Base, Login, Password);
Connection = OPI_MySQL.CreateConnection(ConnectionString);
// CREATE
QueryText = "
|CREATE TABLE test_table (
|id INT AUTO_INCREMENT PRIMARY KEY,
|name VARCHAR(255),
|age INT,
|salary DOUBLE,
|amount FLOAT,
|type TINYINT UNSIGNED,
|date DATE,
|time TIME,
2025-04-02 14:56:42 +03:00
|data MEDIUMBLOB
2025-03-27 20:05:59 +03:00
|);";
Result = OPI_MySQL.ExecuteSQLQuery(QueryText, , , Connection);
// INSERT with parameters
QueryText = "
|INSERT INTO test_table (name, age, salary, amount, type, date, time, data)
|VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
ParameterArray = New Array;
ParameterArray.Add(New Structure("TEXT" , "Vitaly"));
ParameterArray.Add(New Structure("INT" , 25));
ParameterArray.Add(New Structure("DOUBLE", 1000.12));
ParameterArray.Add(New Structure("FLOAT" , 1000.12));
ParameterArray.Add(New Structure("UINT" , 1));
ParameterArray.Add(New Structure("DATE" , OPI_Tools.GetCurrentDate()));
ParameterArray.Add(New Structure("TIME" , OPI_Tools.GetCurrentDate()));
ParameterArray.Add(New Structure("BYTES" , Image));
Result = OPI_MySQL.ExecuteSQLQuery(QueryText, ParameterArray, , Connection);
// SELECT (The result of this query is shown in the Result block)
QueryText = "SELECT name, age, salary, amount, type, date, time, data FROM test_table;";
Result = OPI_MySQL.ExecuteSQLQuery(QueryText, , , Connection);
2025-04-03 21:52:31 +03:00
// SQL query from file
2025-06-27 11:47:43 +03:00
SQLFile = FunctionParameters["SQL2"]; // Binary Data, URL or path to file
2025-04-03 21:52:31 +03:00
Result = OPI_MySQL.ExecuteSQLQuery(SQLFile, , , Connection);
2025-03-27 20:05:59 +03:00
Closing = OPI_MySQL.CloseConnection(Connection);