FNC_GetCounter

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-09-04 18:36:27 -07:00
parent fe9a78c547
commit 44b98fe67b

View File

@@ -9960,34 +9960,45 @@ Public Class ClsContPAQi
Public Function FNC_GetCounter() As Boolean
Dim Retorno = False
StrSQL.Clear()
StrSQL.Append(" IF OBJECT_ID ('FNC_GetCounter') IS NOT NULL DROP FUNCTION FNC_GetCounter")
SqlDataAdapter(StrSQL.ToString, CommandType.Text)
'StrSQL.Clear()
'StrSQL.Append(" IF OBJECT_ID ('FNC_GetCounter') IS NOT NULL DROP FUNCTION FNC_GetCounter")
'SqlDataAdapter(StrSQL.ToString, CommandType.Text)
Try
SqlAdapter.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
Me.OnError("Ocurrió un error al eliminar la funcion FNC_GetCounter", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
End Try
'Try
' SqlAdapter.SelectCommand.ExecuteNonQuery()
'Catch ex As Exception
' Me.OnError("Ocurrió un error al eliminar la funcion FNC_GetCounter", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
'End Try
StrSQL.Clear()
StrSQL.Append(" CREATE FUNCTION [dbo].[FNC_GetCounter] ")
StrSQL.Append(" ( ")
StrSQL.Append(" @TipoCounter VARCHAR(200) ")
StrSQL.Append(" ) ")
StrSQL.Append(" RETURNS INT ")
StrSQL.Append(" AS ")
StrSQL.Append(" BEGIN ")
StrSQL.Append(" ")
StrSQL.Append(" DECLARE @Id INT; ")
StrSQL.Append(" ")
StrSQL.Append(" SELECT @Id = C.Next ")
StrSQL.Append(" FROM Counters C ")
StrSQL.Append(" WHERE C.Name = @TipoCounter; ")
StrSQL.Append(" ")
StrSQL.Append(" RETURN @Id; ")
StrSQL.Append(" END; ")
'StrSQL.Append(" CREATE FUNCTION [dbo].[FNC_GetCounter] ")
'StrSQL.Append(" ( ")
'StrSQL.Append(" @TipoCounter VARCHAR(200) ")
'StrSQL.Append(" ) ")
'StrSQL.Append(" RETURNS INT ")
'StrSQL.Append(" AS ")
'StrSQL.Append(" BEGIN ")
'StrSQL.Append(" ")
'StrSQL.Append(" DECLARE @Id INT; ")
'StrSQL.Append(" ")
'StrSQL.Append(" SELECT @Id = C.Next ")
'StrSQL.Append(" FROM Counters C ")
'StrSQL.Append(" WHERE C.Name = @TipoCounter; ")
'StrSQL.Append(" ")
'StrSQL.Append(" RETURN @Id; ")
'StrSQL.Append(" END; ")
StrSQL.AppendLine(" IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE type = 'FN' AND name = 'FNC_GetCounter')")
StrSQL.AppendLine(" BEGIN")
StrSQL.AppendLine(" DECLARE @sql NVARCHAR(MAX);")
StrSQL.AppendLine(" SET @sql = N'CREATE FUNCTION [dbo].[FNC_GetCounter] ")
StrSQL.AppendLine(" (@TipoCounter VARCHAR(200))")
StrSQL.AppendLine(" RETURNS INT AS ")
StrSQL.AppendLine(" BEGIN ")
StrSQL.AppendLine(" DECLARE @Id INT;SELECT @Id = C.Next FROM Counters C WHERE C.Name = @TipoCounter;RETURN @Id; ")
StrSQL.AppendLine(" END;';")
StrSQL.AppendLine(" EXEC sp_executesql @sql;")
StrSQL.AppendLine(" END")