1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| USE BASE
DECLARE @TypeId INT
DECLARE @EvenementId INT
DECLARE @DateId INT
DECLARE @TitreId INT
-- Création ou récupération du type
IF(SELECT DISTINCT count(TypeName) FROM aspnet_PhotoType WHERE TypeName = 'TypeTest') = '1'
BEGIN
SELECT @TypeId = TypeId FROM aspnet_PhotoType WHERE TypeName = 'TypeTest'
END
ELSE
BEGIN
INSERT INTO aspnet_PhotoType (TypeName) values('TypeTest')
SET @TypeId = @@Identity
END
-- Création ou récupération de l'événement
IF(SELECT DISTINCT count(EvenementName) FROM aspnet_PhotoEvenement WHERE EvenementName = 'EvenementTest2') = '1'
BEGIN
SELECT @EvenementId = EvenementId FROM aspnet_PhotoEvenement WHERE EvenementName = 'EvenementTest2'
END
ELSE
BEGIN
INSERT INTO aspnet_PhotoEvenement (TypeId,EvenementName) values(@TypeId,'EvenementTest2')
SET @EvenementId = @@Identity
END
-- Création ou récupération de la date
IF(SELECT DISTINCT count(Date) FROM aspnet_PhotoDate WHERE Date = '01/01/2001') = '1'
BEGIN
SELECT @DateId = DateId FROM aspnet_PhotoDate WHERE Date = '01/01/2001'
END
ELSE
BEGIN
INSERT INTO aspnet_PhotoDate (EvenementId,Date) values(@EvenementId,'01/01/2001')
SET @DateId = @@Identity
END
--Creation d'un titre
INSERT INTO aspnet_PhotoTitre (DateId,TitreName,TitreNbPhotos,TitreCommentaire,TitrePath,VignettePath) VALUES (@DateId,'TitreTest','12','CommentaireTest','CheminTest','CheminVignetteTest')
SET @TitreId = @@Identity |
Partager