1.新增存储过程判断是否存在

2.已加入 SqlServer、MySql、Oracle
This commit is contained in:
apgk 2022-11-22 14:32:48 +08:00
parent 53dd753736
commit b8185131c1
12 changed files with 34 additions and 4 deletions

View File

@ -598,6 +598,10 @@ namespace SqlSugar
this.Context.Ado.ExecuteCommand(sql);
return true;
}
public virtual bool IsAnyProcedure(string procName) {
string sql = string.Format(this.IsAnyProcedureSql, procName);
return this.Context.Ado.GetInt(sql)>0;
}
#endregion
#region Private

View File

@ -55,6 +55,7 @@ namespace SqlSugar
protected abstract string DeleteTableRemarkSql { get; }
protected abstract string IsAnyTableRemarkSql { get; }
protected abstract string RenameTableSql { get; }
protected abstract string IsAnyProcedureSql { get; }
#endregion
#region Check

View File

@ -25,6 +25,7 @@ namespace SqlSugar
bool IsIdentity(string tableName, string column);
bool IsAnyConstraint(string ConstraintName);
bool IsAnySystemTablePermissions();
bool IsAnyProcedure(string procName);
#endregion
#region DDL

View File

@ -218,6 +218,7 @@ namespace SqlSugar
return "alter table {0} rename to {1}";
}
}
protected override string IsAnyProcedureSql => throw new NotImplementedException();
#endregion
#region Check

View File

@ -195,7 +195,7 @@ namespace SqlSugar
return " Select count(1) from (SELECT to_regclass('Index_UnitCodeTest1_Id_CreateDate') as c ) t where t.c is not null";
}
}
protected override string IsAnyProcedureSql => throw new NotImplementedException();
#endregion
#region Check

View File

@ -153,6 +153,13 @@ namespace SqlSugar
return "alter table {0} change column {1} {2}";
}
}
protected override string IsAnyProcedureSql
{
get
{
return "select count(*) from information_schema.Routines where ROUTINE_NAME='{0}' and ROUTINE_TYPE='PROCEDURE'";
}
}
#endregion
#region Check

View File

@ -221,6 +221,13 @@ namespace SqlSugar
return "alter table {0} rename to {1}";
}
}
protected override string IsAnyProcedureSql
{
get
{
return "SELECT COUNT(*) FROM user_objects WHERE OBJECT_TYPE = 'PROCEDURE' AND OBJECT_NAME ='{0}'";
}
}
#endregion
#region Check

View File

@ -194,6 +194,7 @@ namespace SqlSugar
return " Select count(1) from (SELECT to_regclass('{0}') as c ) t where t.c is not null";
}
}
protected override string IsAnyProcedureSql => throw new NotImplementedException();
#endregion

View File

@ -204,7 +204,7 @@ namespace SqlSugar
return " SELECT count(1) WHERE upper('{0}') IN ( SELECT upper(indexname) FROM pg_indexes )";
}
}
protected override string IsAnyProcedureSql => throw new NotImplementedException();
#endregion
#region Check

View File

@ -170,7 +170,7 @@ namespace SqlSugar
return " Select count(1) from (SELECT to_regclass('{0}') as c ) t where t.c is not null";
}
}
protected override string IsAnyProcedureSql => throw new NotImplementedException();
#endregion
#region Check

View File

@ -269,6 +269,13 @@ namespace SqlSugar
return "select count(*) from sys.indexes where name='{0}'";
}
}
protected override string IsAnyProcedureSql
{
get
{
return "select count(*) from sys.objects where [object_id] = OBJECT_ID(N'sp_GetSubLedgerJoinWithdrawalApplicationRecords') and [type] in (N'P')";
}
}
#endregion
#region Check
@ -563,7 +570,7 @@ namespace SqlSugar
string sql = string.Format(this.RenameColumnSql, tableName, oldColumnName, newColumnName);
this.Context.Ado.ExecuteCommand(sql);
return true;
}
}
#endregion
}
}

View File

@ -136,6 +136,7 @@ namespace SqlSugar
throw new NotSupportedException();
}
}
protected override string IsAnyProcedureSql => throw new NotImplementedException();
#endregion
#region Check