ProjetThe/ProjetTheAlone/Model - Copie/P_T_beneficiaire.sql

57 lines
1.6 KiB
MySQL
Raw Normal View History

2019-01-24 22:24:05 +01:00
CREATE PROCEDURE AjouterT_beneficiaire
@ID_beneficiaire int OUTPUT,
@B_nom varchar(50),
@B_prenom varchar(50),
@B_anniversaire datetime,
@B_img nchar(10)
AS
INSERT INTO T_beneficiaire(B_nom,B_prenom,B_anniversaire,B_img)
VALUES(@B_nom,@B_prenom,@B_anniversaire,@B_img)
SET @ID_beneficiaire=@@IDENTITY
RETURN
GO
CREATE PROCEDURE ModifierT_beneficiaire
@ID_beneficiaire int,
@B_nom varchar(50),
@B_prenom varchar(50),
@B_anniversaire datetime,
@B_img nchar(10)
AS
IF(@ID_beneficiaire IS NULL OR @ID_beneficiaire=0)
RAISERROR('Identifiant requis !',16,1)
ELSE UPDATE T_beneficiaire
SET B_nom=@B_nom,B_prenom=@B_prenom,B_anniversaire=@B_anniversaire,B_img=@B_img
WHERE ID_beneficiaire=@ID_beneficiaire
RETURN
GO
CREATE PROCEDURE SelectionnerT_beneficiaire
@Index VARCHAR(10)
AS
IF(@Index='B_nom') SELECT * FROM T_beneficiaire ORDER BY B_nom
ELSE IF(@Index='B_prenom') SELECT * FROM T_beneficiaire ORDER BY B_prenom
ELSE IF(@Index='B_anniversaire') SELECT * FROM T_beneficiaire ORDER BY B_anniversaire
ELSE IF(@Index='B_img') SELECT * FROM T_beneficiaire ORDER BY B_img
ELSE SELECT * FROM T_beneficiaire ORDER BY ID_beneficiaire
RETURN
GO
CREATE PROCEDURE SelectionnerT_beneficiaire_ID
@ID_beneficiaire int
AS
IF(@ID_beneficiaire IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
SELECT ID_beneficiaire,B_nom,B_prenom,B_anniversaire,B_img
FROM T_beneficiaire
WHERE @ID_beneficiaire=ID_beneficiaire
RETURN
GO
CREATE PROCEDURE SupprimerT_beneficiaire
@ID_beneficiaire int
AS
IF(@ID_beneficiaire IS NULL)
RAISERROR('Identifiant requis !',16,1)
ELSE
DELETE FROM T_beneficiaire WHERE @ID_beneficiaire=ID_beneficiaire
RETURN
GO