ProjetThe/ProjetTheAlone/Model - Copie/P_T_repa.sql

51 lines
1.1 KiB
MySQL
Raw Normal View History

2019-01-24 22:24:05 +01:00
CREATE PROCEDURE AjouterT_repa
@ID_repa int OUTPUT,
@ID_listPlat int,
@ID_typeRepa int
AS
INSERT INTO T_repa(ID_listPlat,ID_typeRepa)
VALUES(@ID_listPlat,@ID_typeRepa)
SET @ID_repa=@@IDENTITY
RETURN
GO
CREATE PROCEDURE ModifierT_repa
@ID_repa int,
@ID_listPlat int,
@ID_typeRepa int
AS
IF(@ID_repa IS NULL OR @ID_repa=0)
RAISERROR('Identifiant requis !',16,1)
ELSE UPDATE T_repa
SET ID_listPlat=@ID_listPlat,ID_typeRepa=@ID_typeRepa
WHERE ID_repa=@ID_repa
RETURN
GO
CREATE PROCEDURE SelectionnerT_repa
@Index VARCHAR(10)
AS
IF(@Index='ID_listPlat') SELECT * FROM T_repa ORDER BY ID_listPlat
ELSE IF(@Index='ID_typeRepa') SELECT * FROM T_repa ORDER BY ID_typeRepa
ELSE SELECT * FROM T_repa ORDER BY ID_repa
RETURN
GO
CREATE PROCEDURE SelectionnerT_repa_ID
@ID_repa int
AS
IF(@ID_repa IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
SELECT ID_repa,ID_listPlat,ID_typeRepa
FROM T_repa
WHERE @ID_repa=ID_repa
RETURN
GO
CREATE PROCEDURE SupprimerT_repa
@ID_repa int
AS
IF(@ID_repa IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
DELETE FROM T_repa WHERE @ID_repa=ID_repa
RETURN
GO