protected override void ExecuteStatement(ExecutionContext context)
{
if (!context.DirectAccess.ObjectExists(DbObjectType.Routine, ProcedureName)) {
if (IfExists)
return;
throw new ObjectNotFoundException(ProcedureName);
}
//if (!context.User.CanDrop(DbObjectType.Routine, ProcedureName))
// throw new MissingPrivilegesException(context.User.Name, ProcedureName, Privileges.Drop);
var routine = context.DirectAccess.GetObject(DbObjectType.Routine, ProcedureName);
if (!(routine is IProcedure))
throw new InvalidOperationException(String.Format("The routine '{0}' is not a procedure.", ProcedureName));
if (!context.DirectAccess.DropObject(DbObjectType.Routine, ProcedureName))
throw new InvalidOperationException(String.Format("Unable to drop the procedure '{0}' from the system.", ProcedureName));
}