dbo.dossier_edita_form_prensa

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

5
Name Data Type Length Description
@p_id_contraparte int 4
@p_contenido varchar -1
@p_creado_por int 4
@p_modificado_por int 4
@p_gestion int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Patricio Lecolant>
-- Create date: <02 julio 2019>
-- Description: <Inserta o edita info prensa >
-- Metodo: procesaFormularioPrensa(DossierController) 
-- =============================================
CREATE OR ALTER PROCEDURE dbo.dossier_edita_form_prensa

@p_id_contraparte int,
@p_contenido VARCHAR(max),
@p_creado_por int,
@p_modificado_por int,
@p_gestion int

AS

BEGIN
    SET NOCOUNT ON;

 --declare @id_gestion int = (select gestion from LN_gestiones where contraparte = @p_id_contraparte) no lo uso, traigo 'gestion' del form
 declare @registro_existente int = (select count(*) from ln_dossier_prensa where contraparte =@p_id_contraparte and gestion = @p_gestion)

    IF (@registro_existente> 0) 
        --UPDATE
        begin try
            UPDATE ln_dossier_prensa
            SET 
                texto_prensa = @p_contenido,
                modified = getdate(),
                modified_by = @p_modificado_por       
            WHERE 
                contraparte = @p_id_contraparte and gestion = @p_gestion
            select 'ok_update' as ok
        end TRY

        begin catch
            select ERROR_MESSAGE() as 'error' 
        end catch
    ELSE
        --INSERT
            begin try
                insert into ln_dossier_prensa (
                    contraparte,
                    gestion,
                    created,
                    created_by,
                    modified,
                    modified_by,
                    texto_prensa,
                    visible
                    ) 
                values (
                    @p_id_contraparte,
                    @p_gestion,
                    getdate(),
                    @p_creado_por,
                    NULL,
                    NULL,
                    @p_contenido,
                    '1'
                    )
            
                select 'ok_insert' as ok
            end try

            begin catch
                select ERROR_MESSAGE() as 'error' 
            end catch

END

GO

Depends On

1

Used By

No items found