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);
}