private void CreateExternProc1(IQuery query) { var procName = ObjectName.Parse("APP.extProc"); var args = new[] { new RoutineParameter("a", PrimitiveTypes.String()), new RoutineParameter("b", PrimitiveTypes.String(), ParameterDirection.Output) }; var externRef = ExternalRef.MakeRef(typeof(TestClass), "Procedure(string, string)"); var procInfo = new ExternalProcedureInfo(procName, args, externRef); query.Access().CreateObject(procInfo); }
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); }