Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
9| Name | Data Type | Length | Description |
|---|---|---|---|
| @CUIT | numeric | 9 | |
| @TipoDoc | varchar | 4 | |
| @contacto1 | varchar | 50 | |
| @email1 | varchar | 50 | |
| @telefono1 | varchar | 30 | |
| @contacto2 | varchar | 50 | |
| @email2 | varchar | 50 | |
| @telefono2 | varchar | 30 | |
| @comentarios | varchar | -1 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
exec Habeas_Data_Solicitud_2022 '20177260909','CUIT','ALE1','EMAIL1','TELEF1','ALE2','EMAIL2','TELEF2','PROBANDO LOS CAMBIOS'
*/
CREATE OR ALTER PROCEDURE dbo.Habeas_Data_Solicitud_2022
@CUIT numeric,
@TipoDoc varchar(4),
@contacto1 varchar(50),
@email1 varchar(50),
@telefono1 varchar(30),
@contacto2 varchar(50),
@email2 varchar(50),
@telefono2 varchar(30),
@comentarios varchar(max)
AS
BEGIN
SET NOCOUNT ON;
/*
declare @cuit varchar(20) = '20177260909'
*/
declare @InformePpal bigint = 0 /*ABS(CHECKSUM(NewId())) % 99999999*/
declare @SubInforme bigint = 0
declare @historial_informe varchar(max)
/*declare @UserID int = 19160464*/
/* Gabriel Galeano */
declare @UserID int = 58829932
/* Cristina Chessa - comentar al regreso de Galeano
SET @UserID = 76475404*/
/* Gabriel Galeano */
declare @UserIDSubInforme int = 58829932
/* Cristina Chessa - comentar al regreso de Galeano
SET @UserIDSubInforme = 76475404*/
declare @cliente int = 2254875
declare @idioma int = 29523
declare @IDTipoInforme int = 671260
declare @filial int = 13136
declare @prioridad tinyint = 5
declare @archivo int = 0 /*ABS(CHECKSUM(NewId())) % 99999999*/
/*
exec @InformePpal = Genera_ID_Informe
*/
/* INFORME PRINCIPAL SE PASA EL SEGUNDO PARÁMETRO DE INFORME PADRE COMO NULL */
exec @InformePpal = Genera_ID_Informe_2022 @cliente,null
/*
DECLARE @OutputTbl TABLE (IDREG INT)
INSERT INTO informes (cliente,informe)
OUTPUT INSERTED.idreg INTO @OutputTbl(IDREG)
values (@cliente,0)
SELECT @InformePpal = IDREG FROM @OutputTbl;
--SELECT @InformePpal AS InformePpal
--UPDATE INFORMES SET INFORME = @InformePpal WHERE IDREG=@InformePpal
*/
select @historial_informe = '[' + last_name + ' ' + first_name + ' - ' + FORMAT( getdate(), 'dd/MM/yyyy HH:mm', 'en-US' ) + ']: Creación del informe.' from users where user_id=@UserID
BEGIN TRY
/*UPDATE INFORMES SET INFORME = @InformePpal,
cliente = @cliente,*/
UPDATE INFORMES SET numero = @CUIT,
identificador = @TipoDoc,
fecha_ingreso = GETDATE(),
prioridad =@prioridad ,
estado_informe = 'E',
filial = @filial,
ingresado_por = @UserID,
idioma = @idioma,
datamanager = @UserID,
asignado = @UserID,
id_tipo_informe =@IDTipoInforme ,
--informe_padre = NULL,
orden=NULL,
historial_informe =@historial_informe ,
objeto_informe = @comentarios,
nombre_contacto_1 = @contacto1,
email_contacto_1 = @email1,
telefono_contacto_1 =@telefono1 ,
nombre_contacto_2 =@contacto2 ,
email_contacto_2 =@email2 ,
telefono_contacto_2 =@telefono2 ,
fecha_inicio = getdate(),
fecha_iniciado = getdate(),
fecha_asignado = getdate(),
fecha_aceptacion = getdate(),
fecha_comprometida = getdate() + 5
WHERE IDREG=@InformePpal
/*
INSERT INTO informes (informe, cliente, numero, identificador, fecha_ingreso, prioridad, estado_informe, filial,
ingresado_por, idioma, datamanager, asignado, id_tipo_informe, informe_padre, orden,historial_informe,
objeto_informe,nombre_contacto_1,email_contacto_1,telefono_contacto_1,nombre_contacto_2,email_contacto_2,telefono_contacto_2,
fecha_inicio,fecha_iniciado,fecha_asignado,fecha_aceptacion,fecha_comprometida)
SELECT @InformePpal as informe, @cliente AS cliente, @CUIT AS numero, @TipoDoc AS identificador, GETDATE() AS fecha_ingreso, @prioridad AS prioridad, 'E' AS estado_informe, @filial AS filial,
@UserID AS ingresado_por, @idioma AS idioma, @UserID AS datamanager, @UserID AS asignado, @IDTipoInforme AS id_tipo_informe, NULL AS informe_padre, NULL AS orden,@historial_informe as historial_informe,
@comentarios as objeto_informe,
@contacto1 as nombre_contacto_1,
@email1 as email_contacto_1,
@telefono1 as telefono_contacto_1,
@contacto2 as nombre_contacto_2,
@email2 as email_contacto_2,
@telefono2 as telefono_contacto_2,
getdate(),
getdate(),
getdate(),
getdate(),
getdate() + 5
*/
DECLARE @Orden INT,@id_tipo_subinforme INT
DECLARE SubInformes Cursor
FOR
SELECT orden, id_tipo_subinforme AS ID_TIPO_INFORME from tipos_subinformes where id_tipo_informe = @IDTipoInforme
Open SubInformes
Fetch NEXT FROM SubInformes INTO @Orden,@id_tipo_subinforme
While (@@FETCH_STATUS <> -1)
BEGIN
-- exec @SubInforme = Genera_ID_Informe
/* TAREAS SE PASA EL SEGUNDO PARÁMETRO DE INFORME PADRE PARA QUE SE ASOCIEN */
exec @SubInforme = Genera_ID_Informe_2022 @cliente,@InformePpal
/*
INSERT INTO informes (informe, cliente, numero, identificador, fecha_ingreso, prioridad, estado_informe, filial,
ingresado_por, idioma, datamanager, asignado, id_tipo_informe, informe_padre, orden,historial_informe,
objeto_informe,nombre_contacto_1,email_contacto_1,telefono_contacto_1,nombre_contacto_2,email_contacto_2,telefono_contacto_2,
fecha_inicio,fecha_asignado,fecha_comprometida) values
(@SubInforme,@cliente,@CUIT,@TipoDoc,GETDATE(),@prioridad,'A',@filial,
@UserID,@idioma,@UserID, @UserIDSubInforme,@id_tipo_subinforme,@InformePpal,@Orden,@historial_informe,
@comentarios,@contacto1,@email1,@telefono1,@contacto2,@email2,@telefono2,
getdate(),getdate(),getdate() + 3)
*/
UPDATE informes set numero = @CUIT, identificador=@TipoDoc, fecha_ingreso=GETDATE(), prioridad=@prioridad, estado_informe='A', filial=@filial,
ingresado_por=@UserID, idioma=@idioma, datamanager=@UserID, asignado= @UserIDSubInforme, id_tipo_informe=@id_tipo_subinforme, orden=@Orden,historial_informe=@historial_informe,
objeto_informe=@comentarios,nombre_contacto_1=@contacto1,email_contacto_1=@email1,telefono_contacto_1=@telefono1,nombre_contacto_2=@contacto2,email_contacto_2=@email2,telefono_contacto_2=@telefono2,
fecha_inicio= getdate(),fecha_asignado= getdate(),fecha_comprometida= getdate()+3
WHERE IDREG=@SubInforme
Fetch NEXT FROM SubInformes INTO @Orden,@id_tipo_subinforme
END
CLOSE SubInformes
DEALLOCATE SubInformes
END TRY
BEGIN CATCH
END CATCH
select @InformePpal as 'habeas_data'
END
GO
GO
/*
exec Habeas_Data_Solicitud_2022 '20177260909','CUIT','ALE1','EMAIL1','TELEF1','ALE2','EMAIL2','TELEF2','PROBANDO LOS CAMBIOS'
*/
CREATE OR ALTER PROCEDURE dbo.Habeas_Data_Solicitud_2022
@CUIT numeric,
@TipoDoc varchar(4),
@contacto1 varchar(50),
@email1 varchar(50),
@telefono1 varchar(30),
@contacto2 varchar(50),
@email2 varchar(50),
@telefono2 varchar(30),
@comentarios varchar(max)
AS
BEGIN
SET NOCOUNT ON;
/*
declare @cuit varchar(20) = '20177260909'
*/
declare @InformePpal bigint = 0 /*ABS(CHECKSUM(NewId())) % 99999999*/
declare @SubInforme bigint = 0
declare @historial_informe varchar(max)
/*declare @UserID int = 19160464*/
/* Gabriel Galeano */
declare @UserID int = 58829932
/* Cristina Chessa - comentar al regreso de Galeano
SET @UserID = 76475404*/
/* Gabriel Galeano */
declare @UserIDSubInforme int = 58829932
/* Cristina Chessa - comentar al regreso de Galeano
SET @UserIDSubInforme = 76475404*/
declare @cliente int = 2254875
declare @idioma int = 29523
declare @IDTipoInforme int = 671260
declare @filial int = 13136
declare @prioridad tinyint = 5
declare @archivo int = 0 /*ABS(CHECKSUM(NewId())) % 99999999*/
/*
exec @InformePpal = Genera_ID_Informe
*/
/* INFORME PRINCIPAL SE PASA EL SEGUNDO PARÁMETRO DE INFORME PADRE COMO NULL */
exec @InformePpal = Genera_ID_Informe_2022 @cliente,null
/*
DECLARE @OutputTbl TABLE (IDREG INT)
INSERT INTO informes (cliente,informe)
OUTPUT INSERTED.idreg INTO @OutputTbl(IDREG)
values (@cliente,0)
SELECT @InformePpal = IDREG FROM @OutputTbl;
--SELECT @InformePpal AS InformePpal
--UPDATE INFORMES SET INFORME = @InformePpal WHERE IDREG=@InformePpal
*/
select @historial_informe = '[' + last_name + ' ' + first_name + ' - ' + FORMAT( getdate(), 'dd/MM/yyyy HH:mm', 'en-US' ) + ']: Creación del informe.' from users where user_id=@UserID
BEGIN TRY
/*UPDATE INFORMES SET INFORME = @InformePpal,
cliente = @cliente,*/
UPDATE INFORMES SET numero = @CUIT,
identificador = @TipoDoc,
fecha_ingreso = GETDATE(),
prioridad =@prioridad ,
estado_informe = 'E',
filial = @filial,
ingresado_por = @UserID,
idioma = @idioma,
datamanager = @UserID,
asignado = @UserID,
id_tipo_informe =@IDTipoInforme ,
--informe_padre = NULL,
orden=NULL,
historial_informe =@historial_informe ,
objeto_informe = @comentarios,
nombre_contacto_1 = @contacto1,
email_contacto_1 = @email1,
telefono_contacto_1 =@telefono1 ,
nombre_contacto_2 =@contacto2 ,
email_contacto_2 =@email2 ,
telefono_contacto_2 =@telefono2 ,
fecha_inicio = getdate(),
fecha_iniciado = getdate(),
fecha_asignado = getdate(),
fecha_aceptacion = getdate(),
fecha_comprometida = getdate() + 5
WHERE IDREG=@InformePpal
/*
INSERT INTO informes (informe, cliente, numero, identificador, fecha_ingreso, prioridad, estado_informe, filial,
ingresado_por, idioma, datamanager, asignado, id_tipo_informe, informe_padre, orden,historial_informe,
objeto_informe,nombre_contacto_1,email_contacto_1,telefono_contacto_1,nombre_contacto_2,email_contacto_2,telefono_contacto_2,
fecha_inicio,fecha_iniciado,fecha_asignado,fecha_aceptacion,fecha_comprometida)
SELECT @InformePpal as informe, @cliente AS cliente, @CUIT AS numero, @TipoDoc AS identificador, GETDATE() AS fecha_ingreso, @prioridad AS prioridad, 'E' AS estado_informe, @filial AS filial,
@UserID AS ingresado_por, @idioma AS idioma, @UserID AS datamanager, @UserID AS asignado, @IDTipoInforme AS id_tipo_informe, NULL AS informe_padre, NULL AS orden,@historial_informe as historial_informe,
@comentarios as objeto_informe,
@contacto1 as nombre_contacto_1,
@email1 as email_contacto_1,
@telefono1 as telefono_contacto_1,
@contacto2 as nombre_contacto_2,
@email2 as email_contacto_2,
@telefono2 as telefono_contacto_2,
getdate(),
getdate(),
getdate(),
getdate(),
getdate() + 5
*/
DECLARE @Orden INT,@id_tipo_subinforme INT
DECLARE SubInformes Cursor
FOR
SELECT orden, id_tipo_subinforme AS ID_TIPO_INFORME from tipos_subinformes where id_tipo_informe = @IDTipoInforme
Open SubInformes
Fetch NEXT FROM SubInformes INTO @Orden,@id_tipo_subinforme
While (@@FETCH_STATUS <> -1)
BEGIN
-- exec @SubInforme = Genera_ID_Informe
/* TAREAS SE PASA EL SEGUNDO PARÁMETRO DE INFORME PADRE PARA QUE SE ASOCIEN */
exec @SubInforme = Genera_ID_Informe_2022 @cliente,@InformePpal
/*
INSERT INTO informes (informe, cliente, numero, identificador, fecha_ingreso, prioridad, estado_informe, filial,
ingresado_por, idioma, datamanager, asignado, id_tipo_informe, informe_padre, orden,historial_informe,
objeto_informe,nombre_contacto_1,email_contacto_1,telefono_contacto_1,nombre_contacto_2,email_contacto_2,telefono_contacto_2,
fecha_inicio,fecha_asignado,fecha_comprometida) values
(@SubInforme,@cliente,@CUIT,@TipoDoc,GETDATE(),@prioridad,'A',@filial,
@UserID,@idioma,@UserID, @UserIDSubInforme,@id_tipo_subinforme,@InformePpal,@Orden,@historial_informe,
@comentarios,@contacto1,@email1,@telefono1,@contacto2,@email2,@telefono2,
getdate(),getdate(),getdate() + 3)
*/
UPDATE informes set numero = @CUIT, identificador=@TipoDoc, fecha_ingreso=GETDATE(), prioridad=@prioridad, estado_informe='A', filial=@filial,
ingresado_por=@UserID, idioma=@idioma, datamanager=@UserID, asignado= @UserIDSubInforme, id_tipo_informe=@id_tipo_subinforme, orden=@Orden,historial_informe=@historial_informe,
objeto_informe=@comentarios,nombre_contacto_1=@contacto1,email_contacto_1=@email1,telefono_contacto_1=@telefono1,nombre_contacto_2=@contacto2,email_contacto_2=@email2,telefono_contacto_2=@telefono2,
fecha_inicio= getdate(),fecha_asignado= getdate(),fecha_comprometida= getdate()+3
WHERE IDREG=@SubInforme
Fetch NEXT FROM SubInformes INTO @Orden,@id_tipo_subinforme
END
CLOSE SubInformes
DEALLOCATE SubInformes
END TRY
BEGIN CATCH
END CATCH
select @InformePpal as 'habeas_data'
END
GO
Depends On
3Used By
No items found