Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
3| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_id_balance | int | 4 | |
| @p_cuit | varchar | 20 | |
| @p_fecha_balance | date | 3 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.backend_control_balances_contables
@p_id_balance int,
@p_cuit varchar(20),
@p_fecha_balance date
AS
BEGIN
SET NOCOUNT ON;
declare @cantidad int
declare @id int
declare @task_id int
declare @fecha date
select @cantidad = count(*),
@fecha = MAX(fecha_balance)
from balances_contables
where cuit = @p_cuit
and year(fecha_balance) = year(@p_fecha_balance)
and month(fecha_balance) = month(@p_fecha_balance)
and id_balance != @p_id_balance
and estado != 'ELIMINADO'
IF (@cantidad != 0)
begin
select top 1 @id = id_balance, @task_id = task_id
from balances_contables
where cuit = @p_cuit
and fecha_balance = @fecha
and estado != 'ELIMINADO'
select '1' as error, 'Ya existe otro registro para ese Mes/Año' as mensaje, @fecha as fecha, @id as id, @task_id as task
end
else
begin
select @cantidad = count(*),
@fecha = MAX(fecha_balance)
from balances_contables
where cuit = @p_cuit
and year(fecha_balance) = year(@p_fecha_balance)
and id_balance != @p_id_balance
and estado != 'ELIMINADO'
IF (@cantidad != 0)
begin
select top 1 @id = id_balance, @task_id = task_id
from balances_contables
where cuit = @p_cuit
and fecha_balance = @fecha
and estado != 'ELIMINADO'
select '2' as error, 'Ya existe otro registro para ese Año' as mensaje, @fecha as fecha, @id as id, @task_id as task
end
else
begin
select '0' as error, 'ok' as mensaje, null as fecha, null as id, null as task
end
end
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.backend_control_balances_contables
@p_id_balance int,
@p_cuit varchar(20),
@p_fecha_balance date
AS
BEGIN
SET NOCOUNT ON;
declare @cantidad int
declare @id int
declare @task_id int
declare @fecha date
select @cantidad = count(*),
@fecha = MAX(fecha_balance)
from balances_contables
where cuit = @p_cuit
and year(fecha_balance) = year(@p_fecha_balance)
and month(fecha_balance) = month(@p_fecha_balance)
and id_balance != @p_id_balance
and estado != 'ELIMINADO'
IF (@cantidad != 0)
begin
select top 1 @id = id_balance, @task_id = task_id
from balances_contables
where cuit = @p_cuit
and fecha_balance = @fecha
and estado != 'ELIMINADO'
select '1' as error, 'Ya existe otro registro para ese Mes/Año' as mensaje, @fecha as fecha, @id as id, @task_id as task
end
else
begin
select @cantidad = count(*),
@fecha = MAX(fecha_balance)
from balances_contables
where cuit = @p_cuit
and year(fecha_balance) = year(@p_fecha_balance)
and id_balance != @p_id_balance
and estado != 'ELIMINADO'
IF (@cantidad != 0)
begin
select top 1 @id = id_balance, @task_id = task_id
from balances_contables
where cuit = @p_cuit
and fecha_balance = @fecha
and estado != 'ELIMINADO'
select '2' as error, 'Ya existe otro registro para ese Año' as mensaje, @fecha as fecha, @id as id, @task_id as task
end
else
begin
select '0' as error, 'ok' as mensaje, null as fecha, null as id, null as task
end
end
END
GO
Depends On
1Used By
No items found