Inheritance: IStatementPreparable, ISqlFormattable
Example #1
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters, DataType returnType, FunctionType functionType)
     : base(routineName, parameters)
 {
     ReturnType = returnType;
     FunctionType = functionType;
     AssertUnboundAtEnd();
 }
Example #2
0
        public PlSqlProcedureInfo(ObjectName procedureName, RoutineParameter[] parameters, SqlStatement body)
            : base(procedureName, parameters)
        {
            if (body == null)
                throw new ArgumentNullException("body");

            Body = body;
        }
Example #3
0
        public ExternalProcedureInfo(ObjectName procedureName, RoutineParameter[] parameters, ExternalRef externalRef)
            : base(procedureName, parameters)
        {
            if (externalRef == null)
                throw new ArgumentNullException("externalRef");

            ExternalRef = externalRef;
        }
Example #4
0
        public ExternalFunctionInfo(ObjectName functionName, RoutineParameter[] parameters, SqlType returnType,
			ExternalRef externalRef)
            : base(functionName, parameters, returnType, FunctionType.Static)
        {
            if (externalRef == null)
                throw new ArgumentNullException("externalRef");

            ExternalRef = externalRef;
        }
        public CreateProcedureStatement(ObjectName procedureName, RoutineParameter[] parameters, SqlStatement body)
        {
            if (procedureName == null)
                throw new ArgumentNullException("procedureName");
            if (body == null)
                throw new ArgumentNullException("body");

            ProcedureName = procedureName;
            Parameters = parameters;
            Body = body;
        }
        public CreateExternalProcedureStatement(ObjectName procedureName, RoutineParameter[] parameters, string externalRef)
        {
            if (procedureName == null)
                throw new ArgumentNullException("procedureName");
            if (String.IsNullOrEmpty(externalRef))
                throw new ArgumentNullException("externalRef");

            ProcedureName = procedureName;
            Parameters = parameters;
            ExternalReference = externalRef;
        }
Example #7
0
        /// <summary>
        /// Constructs the routine info with the given signature.
        /// </summary>
        /// <param name="routineName">The name uniquely identifying the routine.</param>
        /// <param name="parameters">The list of parameter information of the routine.</param>
        protected RoutineInfo(ObjectName routineName, RoutineParameter[] parameters)
        {
            if (routineName == null)
                throw new ArgumentNullException("routineName");

            if (parameters == null)
                parameters = new RoutineParameter[0];

            RoutineName = routineName;
            Parameters = parameters;
            Body = new RoutineBody(this);
        }
        public CreateFunctionStatement(ObjectName functionName, SqlType returnType, RoutineParameter[] parameters, SqlStatement body)
        {
            if (functionName == null)
                throw new ArgumentNullException("functionName");
            if (returnType == null)
                throw new ArgumentNullException("returnType");
            if (body == null)
                throw new ArgumentNullException("body");

            FunctionName = functionName;
            ReturnType = returnType;
            Parameters = parameters;
            Body = body;
        }
        public CreateExternalFunctionStatement(ObjectName functionName, SqlType returnType,  RoutineParameter[] parameters, string externalRef)
        {
            if (functionName == null)
                throw new ArgumentNullException("functionName");
            if (returnType == null)
                throw new ArgumentNullException("returnType");
            if (String.IsNullOrEmpty(externalRef))
                throw new ArgumentNullException("externalRef");

            FunctionName = functionName;
            ReturnType = returnType;
            Parameters = parameters;
            ExternalReference = externalRef;
        }
Example #10
0
        public PlSqlFunctionInfo(ObjectName functionName, RoutineParameter[] parameters, SqlType returnType, SqlStatement body)
            : base(functionName, parameters,returnType, FunctionType.Static)
        {
            if (body == null)
                throw new ArgumentNullException("body");

            // TODO: in case of RETURNS TABLE verify a select is there
            if (!(returnType is TabularType)) {
                if (!ReturnChecker.HasReturn(body))
                    throw new ArgumentException("The function body has no return");
            }

            Body = body;
        }
Example #11
0
        /// <summary>
        /// Constructs the routine info with the given signature.
        /// </summary>
        /// <param name="routineName">The name uniquely identifying the routine.</param>
        /// <param name="parameters">The list of parameter information of the routine.</param>
        protected RoutineInfo(ObjectName routineName, RoutineParameter[] parameters)
        {
            if (routineName == null)
            {
                throw new ArgumentNullException("routineName");
            }

            if (parameters == null)
            {
                parameters = new RoutineParameter[0];
            }

            RoutineName = routineName;
            Parameters  = parameters;
            // TODO: Body = new RoutineBody(this);
        }
Example #12
0
        public void CreateExternalFunction()
        {
            var funName = ObjectName.Parse("APP.fun1");
            var parameters = new RoutineParameter[] {
                new RoutineParameter("a", PrimitiveTypes.Integer()),
                new RoutineParameter("b", PrimitiveTypes.Integer()),
            };

            var externRef = ExternalRef.MakeRef(typeof(Test), "Function(int, int)");
            AdminQuery.CreateExternFunction(funName, PrimitiveTypes.Integer(), parameters, externRef.ToString());

            var exists = AdminQuery.Access().RoutineExists(funName);

            Assert.IsTrue(exists);

            var function = AdminQuery.Access().GetObject(DbObjectType.Routine, funName);

            Assert.IsNotNull(function);
            Assert.IsInstanceOf<ExternalFunction>(function);

            var externFunction = (ExternalFunction) function;
            Assert.IsNotNull(externFunction.ExternalRef);
            Assert.AreEqual(typeof(Test), externFunction.ExternalRef.Type);
        }
Example #13
0
        public void CreateExternalProcedure()
        {
            var procName = ObjectName.Parse("APP.proc1");
            var parameters = new RoutineParameter[] {
                new RoutineParameter("a", PrimitiveTypes.Integer()),
                new RoutineParameter("b", PrimitiveTypes.Integer()),
            };

            var externRef = ExternalRef.MakeRef(typeof(Test), "Procedure(int, int)");
            AdminQuery.CreateExternProcedure(procName, parameters, externRef.ToString());

            var exists = AdminQuery.Access().RoutineExists(procName);

            Assert.IsTrue(exists);

            var procedure = AdminQuery.Access().GetObject(DbObjectType.Routine, procName);

            Assert.IsNotNull(procedure);
            Assert.IsInstanceOf<ExternalProcedure>(procedure);

            var externFunction = (ExternalProcedure)procedure;
            Assert.IsNotNull(externFunction.ExternalRef);
            Assert.AreEqual(typeof(Test), externFunction.ExternalRef.Type);
        }
        protected override void ExecuteStatement(ExecutionContext context)
        {
            //if (!context.User.CanCreateInSchema(ProcedureName.ParentName))
            //	throw new SecurityException();

            if (context.DirectAccess.RoutineExists(ProcedureName)) {
                if (!ReplaceIfExists)
                    throw new StatementException(String.Format("A routine named '{0}' already exists in the database.", ProcedureName));

                context.DirectAccess.DeleteRoutine(ProcedureName);
            }

            var parameters = new RoutineParameter[0];
            if (Parameters != null)
                parameters = Parameters.ToArray();

            ExternalRef externRef;
            if (!ExternalRef.TryParse(ExternalReference, out externRef))
                throw new FormatException(String.Format("The external reference '{0}' is not valid.", ExternalReference));

            var functionInfo = new ExternalProcedureInfo(ProcedureName, parameters, externRef) {
                Owner = context.User.Name
            };

            context.DirectAccess.CreateRoutine(functionInfo);
            //context.DirectAccess.GrantOn(DbObjectType.Routine, ProcedureName, context.User.Name, Privileges.Execute, true);
        }
 protected AggregateFunction(ObjectName name, RoutineParameter[] parameters, SqlType returnType)
     : base(name, parameters, returnType, FunctionType.Aggregate)
 {
 }
Example #16
0
 public ProcedureInfo(ObjectName routineName, RoutineParameter[] parameters)
     : this(routineName, ProcedureType.Static, parameters)
 {
 }
Example #17
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters)
     : this(routineName, parameters, FunctionType.Static)
 {
 }
        protected override void ExecuteStatement(ExecutionContext context)
        {
            //if (!context.User.CanCreateInSchema(FunctionName.ParentName))
            //	throw new SecurityException();

            if (context.DirectAccess.RoutineExists(FunctionName)) {
                if (!ReplaceIfExists)
                    throw new StatementException(String.Format("A routine named '{0}' already exists in the database.", FunctionName));

                context.DirectAccess.DeleteRoutine(FunctionName);
            }

            var parameters = new RoutineParameter[0];
            if (Parameters != null)
                parameters = Parameters.ToArray();

            var functionInfo = new PlSqlFunctionInfo(FunctionName, parameters, ReturnType, Body) {
                Owner = context.User.Name
            };

            context.DirectAccess.CreateRoutine(functionInfo);
            //context.DirectAccess.GrantOn(DbObjectType.Routine, FunctionName, context.User.Name, Privileges.Execute, true);
        }
Example #19
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters, FunctionType functionType)
     : this(routineName, parameters, null, functionType)
 {
 }
Example #20
0
 public UserFunction(ObjectName name, RoutineParameter[] parameters, DataType returnType)
     : base(name, parameters, returnType)
 {
 }
Example #21
0
 public SystemFunctionInfo(string functionName, RoutineParameter[] parameters, SqlType returnType, FunctionType functionType)
     : base(new ObjectName(functionName), parameters, returnType, functionType)
 {
 }
Example #22
0
 public SystemFunctionInfo(string functionName, RoutineParameter[] parameters, FunctionType functionType)
     : this(functionName, parameters, null, functionType)
 {
 }
Example #23
0
 public UserFunction(ObjectName name, RoutineParameter[] parameters, FunctionType functionType)
     : base(name, parameters, functionType)
 {
 }
Example #24
0
 public UserFunction(ObjectName name, RoutineParameter[] parameters, SqlType returnType, FunctionType functionType)
     : base(name, parameters, returnType, functionType)
 {
 }
Example #25
0
 protected Function(ObjectName name, RoutineParameter[] parameters, FunctionType functionType)
     : this(name, parameters, null, functionType)
 {
 }
Example #26
0
 public ProcedureInfo(ObjectName routineName, ProcedureType procedureType, RoutineParameter[] parameters)
     : base(routineName, parameters)
 {
     ProcedureType = procedureType;
 }
Example #27
0
 protected Function(ObjectName name, RoutineParameter[] parameters, SqlType returnType)
     : this(name, parameters, returnType, FunctionType.Static)
 {
 }
Example #28
0
 protected Function(ObjectName name, RoutineParameter[] parameters, SqlType returnType, FunctionType functionType)
     : this(new FunctionInfo(name, parameters, returnType, functionType))
 {
 }
Example #29
0
            private SystemFunctionInfo CreateFunctionInfo(ObjectName typeName, IDictionary<string, SqlType> members)
            {
                var parameters = new RoutineParameter[members.Count];
                int i = -1;
                foreach (var member in members) {
                    parameters[++i] = new RoutineParameter(member.Key, member.Value, ParameterDirection.Input);
                }

                return new SystemFunctionInfo(typeName.FullName, parameters, FunctionType.Static);
            }
Example #30
0
 protected SystemFunction(string name, RoutineParameter[] parameters, SqlType returnType, FunctionType functionType)
     : this(new SystemFunctionInfo(name, parameters, returnType, functionType))
 {
 }
Example #31
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters, DataType returnType)
     : this(routineName, parameters, returnType, FunctionType.Static)
 {
 }