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);
        }
Beispiel #2
0
        protected override bool OnSetUp(string testName, IQuery query)
        {
            var funcName   = ObjectName.Parse("APP.func1");
            var returnType = PrimitiveTypes.String();
            var body       = new PlSqlBlockStatement();

            body.Statements.Add(new ReturnStatement(SqlExpression.Constant("Hello!")));

            var funtionInfo = new PlSqlFunctionInfo(funcName, new RoutineParameter[0], returnType, body);

            query.Access().CreateObject(funtionInfo);

            return(true);
        }
        protected override bool OnSetUp(string testName, IQuery query)
        {
            procName = ObjectName.Parse("APP.proc1");
            var body = new PlSqlBlockStatement();

            body.Statements.Add(new CallStatement(ObjectName.Parse("proc2")));
            var procInfo = new PlSqlProcedureInfo(procName, new RoutineParameter[0], body);

            query.Access().CreateObject(procInfo);

            funcName = ObjectName.Parse("APP.func1");
            body     = new PlSqlBlockStatement();
            body.Statements.Add(new ReturnStatement(SqlExpression.Constant(22)));
            var funcInfo = new PlSqlFunctionInfo(funcName, new RoutineParameter[0], PrimitiveTypes.Integer(), body);

            query.Access().CreateObject(funcInfo);

            return(true);
        }