ProjetThe/ProjetTheAlone/Model/P_T_event.sql

60 lines
1.6 KiB
Transact-SQL

CREATE PROCEDURE AjouterT_event
@ID_event int OUTPUT,
@E_date datetime,
@E_duree datetime,
@ID_typeEvenement int,
@E_description text,
@ID_lieu int
AS
INSERT INTO T_event(E_date,E_duree,ID_typeEvenement,E_description,ID_lieu)
VALUES(@E_date,@E_duree,@ID_typeEvenement,@E_description,@ID_lieu)
SET @ID_event=@@IDENTITY
RETURN
GO
CREATE PROCEDURE ModifierT_event
@ID_event int,
@E_date datetime,
@E_duree datetime,
@ID_typeEvenement int,
@E_description text,
@ID_lieu int
AS
IF(@ID_event IS NULL OR @ID_event=0)
RAISERROR('Identifiant requis !',16,1)
ELSE UPDATE T_event
SET E_date=@E_date,E_duree=@E_duree,ID_typeEvenement=@ID_typeEvenement,E_description=@E_description,ID_lieu=@ID_lieu
WHERE ID_event=@ID_event
RETURN
GO
CREATE PROCEDURE SelectionnerT_event
@Index VARCHAR(10)
AS
IF(@Index='E_date') SELECT * FROM T_event ORDER BY E_date
ELSE IF(@Index='E_duree') SELECT * FROM T_event ORDER BY E_duree
ELSE IF(@Index='ID_typeEvenement') SELECT * FROM T_event ORDER BY ID_typeEvenement
ELSE IF(@Index='E_description') SELECT * FROM T_event ORDER BY E_description
ELSE IF(@Index='ID_lieu') SELECT * FROM T_event ORDER BY ID_lieu
ELSE SELECT * FROM T_event ORDER BY ID_event
RETURN
GO
CREATE PROCEDURE SelectionnerT_event_ID
@ID_event int
AS
IF(@ID_event IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
SELECT ID_event,E_date,E_duree,ID_typeEvenement,E_description,ID_lieu
FROM T_event
WHERE @ID_event=ID_event
RETURN
GO
CREATE PROCEDURE SupprimerT_event
@ID_event int
AS
IF(@ID_event IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
DELETE FROM T_event WHERE @ID_event=ID_event
RETURN
GO