public async Task MultiQueryJSONIsolation() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" }, new InputQuery { InputQueryString = "SELECT * FROM HodorTest" }, new InputQuery { InputQueryString = "INSERT INTO HodorTest values('test', 890)" }, new InputQuery { InputQueryString = "DELETE FROM HodorTest WHERE value = 890" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties(), OutputToFile = false, }; var options = new QueryOptions { ThrowErrorOnFailure = true, IsolationLevel = Oracle_IsolationLevel.Serializable }; var result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); Assert.AreEqual(result.Results.First?["Output"]?.ToString(), "[\r\n {\r\n \"DECIMALVALUE\": 1.123456789123456789123456789\r\n }\r\n]"); Assert.AreEqual(true, result.Success); }
public async Task MultiQuerRollback() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "insert into DecimalTest(DecimalValue) values(10.6)" }, new InputQuery { InputQueryString = "SELECT * FROM foo" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties(), OutputToFile = true, OutputFile = new OutputFileProperties { Path = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString() + ".json") } }; var options = new QueryOptions { ThrowErrorOnFailure = true, IsolationLevel = Oracle_IsolationLevel.Serializable }; var result = new MultiQueryOutput(); try { result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); } catch (Exception) { } var multiQueryProperties2 = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" } }, ConnectionString = ConnectionString }; var outputProperties2 = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties() }; var options2 = new QueryOptions { ThrowErrorOnFailure = true }; var result2 = await OracleTasks.TransactionalMultiQuery(multiQueryProperties2, outputProperties2, options2, new CancellationToken()); Assert.That(() => OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()), Throws.TypeOf <OracleException>()); Assert.AreEqual(false, result.Success); Assert.AreNotEqual(2, result2.Results.Count); File.Delete(outputProperties.OutputFile.Path); }
public async Task MultiqueryShouldWriteXMLFile() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" }, new InputQuery { InputQueryString = "SELECT * FROM HodorTest" }, new InputQuery { InputQueryString = "INSERT INTO HodorTest values('test', 890)" }, new InputQuery { InputQueryString = "DELETE FROM HodorTest WHERE value = 890" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Xml, OutputToFile = true, XmlOutput = new XmlOutputProperties { RootElementName = "items", RowElementName = "item" }, OutputFile = new OutputFileProperties { Path = Path.Combine(outputDirectory, Guid.NewGuid().ToString() + ".json") } }; var options = new QueryOptions { ThrowErrorOnFailure = true }; var result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); Assert.IsTrue(File.Exists(outputProperties.OutputFile.Path)); Assert.IsTrue(File.ReadAllText(result.Results.First?["OutputPath"]?.ToString()).Contains("<DECIMALVALUE>1.12345678912345678912345678912345678</DECIMALVALUE>")); File.Delete(outputProperties.OutputFile.Path); }
public async Task MultiQueryJSON() { var multiQueryProperties = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM DecimalTest" }, new InputQuery { InputQueryString = "SELECT * FROM HodorTest" } }, ConnectionString = ConnectionString }; var outputProperties = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties() }; var options = new QueryOptions { ThrowErrorOnFailure = true }; var result = await OracleTasks.TransactionalMultiQuery(multiQueryProperties, outputProperties, options, new CancellationToken()); Assert.AreNotEqual("", result.Results); Assert.AreEqual(true, result.Success); }
public async Task MultiBatchOpeartionRollback() { var inputbatch = new InputMultiBatchOperation { BatchQueries = new BatchOperationQuery[] { new BatchOperationQuery { BatchInputQuery = @"delete from batch_table_test", InputJson = "" }, new BatchOperationQuery { BatchInputQuery = @"insert into batch_table_test (NR,NAM)values(:NR,:NAM)", InputJson = "[{\"NR\": 111, \"NAM\":\"nannaa1\"},{\"NR\":222, \"NAM\":\"nannaa2\"},{\"NR\":333, \"NAM\":\"nannaa3\"}, {\"NR\":444, \"NAM\":\"nannaa4\"}]" }, new BatchOperationQuery { BatchInputQuery = @"insert into batch_table_testfoo (NR,NAM)values(:NR,:NAM)", InputJson = "[{\"NR\": 555, \"NAM\":\"nannaa1\"},{\"NR\":666, \"NAM\":\"nannaa2\"}]" } }, ConnectionString = ConnectionString }; var options = new BatchOptions { ThrowErrorOnFailure = true, IsolationLevel = Oracle_IsolationLevel.Serializable }; MultiBatchOperationOutput output = new MultiBatchOperationOutput(); try { output = await OracleTasks.MultiBatchOperationOracle(inputbatch, options, new CancellationToken()); } catch (Exception) { } var multiQueryProperties2 = new InputMultiQuery { Queries = new InputQuery[] { new InputQuery { InputQueryString = "SELECT * FROM " } }, ConnectionString = ConnectionString }; var outputProperties2 = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties() }; var options2 = new QueryOptions { ThrowErrorOnFailure = true }; var o = new QueryOutputProperties { ReturnType = QueryReturnType.Json, JsonOutput = new JsonOutputProperties(), OutputToFile = false }; var q2 = new QueryProperties { Query = @"select count(*) as ROWCOUNT from batch_table_test", ConnectionString = ConnectionString }; var options_2 = new QueryOptions(); options.ThrowErrorOnFailure = true; options.IsolationLevel = Oracle_IsolationLevel.Serializable; var result_debug = await OracleTasks.ExecuteQueryOracle(q2, o, options_2, new CancellationToken()); Assert.That(() => OracleTasks.MultiBatchOperationOracle(inputbatch, options, new CancellationToken()), Throws.TypeOf <OracleException>()); Assert.AreEqual(false, output.Success); Assert.AreEqual(result_debug.Result, "[\r\n {\r\n \"ROWCOUNT\": 4.0\r\n }\r\n]"); }