Jump to content
Sign in to follow this  
fearz7

[Resolvido] Sobreposição de datas

Recommended Posts

fearz7

Tenho um problema onde necessito de evitar a introdução de um aluguer a um determinado aluno cuja datas sejam sobrepostas a um já existente, desta forma venho solicitar a vossa ajuda para resolver o problema. Criei o trigger que se segue, e quando introduzo uma data sobreposta é me gerado um "erro" contudo quando nao é sobreposta também me gera esse mesmo "erro", não percebo o porquê.

ALTER TRIGGER [dbo].[ValidarDatas]
ON [dbo].[Aluguer2]
AFTER INSERT, UPDATE
AS
IF EXISTS (SELECT *
FROM inserted i, Aluguer2 a
WHERE a.nrAluno = i.nrAluno AND a.dataEntrada < i.dataSaida AND a.dataSaida >i.dataEntrada)
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
PRINT 'Sobreposicao de datas'
ROLLBACK TRANSACTION
END

Melhores cumprimentos

Edited by apocsantos
geshi

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.