	IF OBJECT_ID('NET_INSERT_ETICKET') IS NOT NULL
		DROP PROC NET_INSERT_ETICKET

	GO
		CREATE PROC NET_INSERT_ETICKET
	(
				 @pCodEticket	int
				,@pHTML	text
				,@pTitulo	varchar(200)
				,@pCodUsuario	nchar(10)
				,@pStatus	int
				,@pDataCadastro	datetime
			,@PMessageErr VARCHAR(150) =  NULL OUTPUT
	)
	AS 
		
		BEGIN
			SET NOCOUNT ON
			
			IF @pCodEticket	 = 0 OR @pCodEticket	 IS NULL 
				BEGIN
		INSERT INTO NET_ETICKET
							(      
								 HTML
								,Titulo
								,CodUsuario
								,DataCadastro
								,Status

							)VALUES
							(
								 @pHTML
								,@pTitulo
								,@pCodUsuario
								,@pDataCadastro
								,@pStatus

							)
			END
		ELSE
	
						UPDATE    NET_ETICKET
									SET               
											 HTML = @pHTML
											,Titulo =@pTitulo 
											,CodUsuario = @pCodUsuario
											,dataUpdate = getdate()
											,Status = @pStatus
									WHERE     
														CodEticket	 = @pCodEticket	;
	

					SELECT @PMessageErr  As MessageReturn;
			SET NOCOUNT OFF 
	END 
