ProjetThe/ProjetTheAlone/Model/P_T_equipe.sql

54 lines
1.3 KiB
MySQL
Raw Normal View History

2019-01-18 13:08:55 +01:00
CREATE PROCEDURE AjouterT_equipe
@ID_equipe int OUTPUT,
@E_nom nchar(10),
@E_point nchar(10),
@ID_evenement int
AS
INSERT INTO T_equipe(E_nom,E_point,ID_evenement)
VALUES(@E_nom,@E_point,@ID_evenement)
SET @ID_equipe=@@IDENTITY
RETURN
GO
CREATE PROCEDURE ModifierT_equipe
@ID_equipe int,
@E_nom nchar(10),
@E_point nchar(10),
@ID_evenement int
AS
IF(@ID_equipe IS NULL OR @ID_equipe=0)
RAISERROR('Identifiant requis !',16,1)
ELSE UPDATE T_equipe
SET E_nom=@E_nom,E_point=@E_point,ID_evenement=@ID_evenement
WHERE ID_equipe=@ID_equipe
RETURN
GO
CREATE PROCEDURE SelectionnerT_equipe
@Index VARCHAR(10)
AS
IF(@Index='E_nom') SELECT * FROM T_equipe ORDER BY E_nom
ELSE IF(@Index='E_point') SELECT * FROM T_equipe ORDER BY E_point
ELSE IF(@Index='ID_evenement') SELECT * FROM T_equipe ORDER BY ID_evenement
ELSE SELECT * FROM T_equipe ORDER BY ID_equipe
RETURN
GO
CREATE PROCEDURE SelectionnerT_equipe_ID
@ID_equipe int
AS
IF(@ID_equipe IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
SELECT ID_equipe,E_nom,E_point,ID_evenement
FROM T_equipe
WHERE @ID_equipe=ID_equipe
RETURN
GO
CREATE PROCEDURE SupprimerT_equipe
@ID_equipe int
AS
IF(@ID_equipe IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
DELETE FROM T_equipe WHERE @ID_equipe=ID_equipe
RETURN
GO