You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-25 22:12:29 +02:00
65 lines
2.4 KiB
Plaintext
Vendored
65 lines
2.4 KiB
Plaintext
Vendored
CurrentDate = OPI_Tools.GetCurrentDate();
|
|
Image = "https://hut.openintegrations.dev/test_data/picture.jpg";
|
|
OPI_TypeConversion.GetBinaryData(Image); // Image - Type: BinaryData
|
|
|
|
Address = "127.0.0.1";
|
|
Login = "SA";
|
|
Password = "12we...";
|
|
Base = "test_data";
|
|
|
|
TLSSettings = OPI_MSSQL.GetTLSSettings(True);
|
|
ConnectionString = OPI_MSSQL.GenerateConnectionString(Address, Base, Login, Password);
|
|
Connection = OPI_MSSQL.CreateConnection(ConnectionString, TLSSettings);
|
|
|
|
// CREATE
|
|
|
|
QueryText = "
|
|
|CREATE TABLE test_table (
|
|
| ID INT PRIMARY KEY,
|
|
| FirstName NVARCHAR(50),
|
|
| LastName NVARCHAR(50),
|
|
| BirthDate DATE,
|
|
| IsEmployed BIT,
|
|
| Salary DECIMAL(10, 2),
|
|
| CreatedAt DATETIME,
|
|
| Age SMALLINT,
|
|
| RowGuid UNIQUEIDENTIFIER,
|
|
| Data VARBINARY(MAX)
|
|
|);";
|
|
|
|
Result = OPI_MSSQL.ExecuteSQLQuery(QueryText, , , Connection);
|
|
|
|
// INSERT with parameters
|
|
|
|
QueryText = "
|
|
|INSERT INTO test_table (ID, FirstName, LastName, BirthDate, IsEmployed, Salary, CreatedAt, Age, RowGuid, Data)
|
|
|VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10);";
|
|
|
|
ParameterArray = New Array;
|
|
ParameterArray.Add(New Structure("INT" , 1));
|
|
ParameterArray.Add(New Structure("NVARCHAR", "Vitaly"));
|
|
ParameterArray.Add(New Structure("NVARCHAR", "Alpaca"));
|
|
ParameterArray.Add(New Structure("DATE" , CurrentDate));
|
|
ParameterArray.Add(New Structure("BIT" , True));
|
|
ParameterArray.Add(New Structure("DECIMAL" , 10.30));
|
|
ParameterArray.Add(New Structure("DATETIME", CurrentDate));
|
|
ParameterArray.Add(New Structure("SMALLINT", 20));
|
|
ParameterArray.Add(New Structure("UUID" , New UUID));
|
|
ParameterArray.Add(New Structure("BYTES" , Image));
|
|
|
|
Result = OPI_MSSQL.ExecuteSQLQuery(QueryText, ParameterArray, , Connection);
|
|
|
|
// SELECT (The result of this query is shown in the Result block)
|
|
|
|
QueryText = "SELECT FirstName, LastName, BirthDate, IsEmployed, Salary, CreatedAt, Age, RowGuid, Data FROM test_table;";
|
|
|
|
Result = OPI_MSSQL.ExecuteSQLQuery(QueryText, , , Connection);
|
|
|
|
// SQL query from file
|
|
|
|
SQLFile = "https://hut.openintegrations.dev/test_data/TEST_DATA2.sql"; // Binary Data, URL or path to file
|
|
|
|
Result = OPI_MSSQL.ExecuteSQLQuery(SQLFile, , , Connection);
|
|
|
|
Closing = OPI_MSSQL.CloseConnection(Connection);
|