Example #1
0
        public void InitialNullIntegerOutputParam()
        {
            var     db        = new SPTestsDatabase();
            dynamic intResult = db.ExecuteWithParams("set @a = 1", outParams: new { a = (int?)null });

            Assert.AreEqual(typeof(int), intResult.a.GetType());
        }
Example #2
0
        public void InitialNullBooleanOutputParam()
        {
            var     db         = new SPTestsDatabase();
            dynamic boolResult = db.ExecuteWithParams("set @a = 1", outParams: new { a = (bool?)null });

            Assert.AreEqual(typeof(bool), boolResult.a.GetType());
        }
Example #3
0
        public void IntegerOutputParam()
        {
            var     db        = new SPTestsDatabase(ProviderName);
            dynamic intResult = db.ExecuteWithParams("begin :a := 1; end;", outParams: new { a = 0 });

            Assert.AreEqual(1, intResult.a);
        }
Example #4
0
        public void InitialNullDateOutputParam()
        {
            var     db         = new SPTestsDatabase(ProviderName);
            dynamic dateResult = db.ExecuteWithParams("begin :d := SYSDATE; end;", outParams: new { d = (DateTime?)null });

            Assert.AreEqual(typeof(DateTime), dateResult.d.GetType());
        }
Example #5
0
        public void PassingCursorInputParameter(bool explicitConnection)
        {
            var db = new SPTestsDatabase(ProviderName, explicitConnection);

            if (explicitConnection)
            {
                MightyTests.ConnectionStringUtils.CheckConnectionStringRequiredForOpenConnection(db);
            }
            // To share cursors between commands in Oracle the commands must use the same connection
            using (var conn = db.OpenConnection(
                       explicitConnection ?
                       MightyTests.ConnectionStringUtils.GetConnectionString(TestConstants.ReadWriteTestConnection, ProviderName) :
                       null
                       ))
            {
                var res1 = db.ExecuteWithParams("begin open :p_rc for select * from emp where deptno = 10; end;", outParams: new { p_rc = new Cursor() }, connection: conn);
                Assert.AreEqual(typeof(Cursor), res1.p_rc.GetType());
                Assert.AreEqual("OracleRefCursor", ((Cursor)res1.p_rc).CursorRef.GetType().Name);

                db.Execute("delete from processing_result", connection: conn);

                // oracle demo code takes the input cursor and writes the results to `processing_result` table
                var res2 = db.ExecuteProcedure("cursor_in_out.process_cursor", inParams: new { p_cursor = res1.p_rc }, connection: conn);
                Assert.AreEqual(0, ((IDictionary <string, object>)res2).Count);

                var processedRows = db.Query("select * from processing_result", connection: conn).ToList();
                Assert.AreEqual(3, processedRows.Count);
            }
        }