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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
DECLARE curs CURSOR local fast_forward
FOR
select strTitre, datCreation, strAuteur, intStatut, strContenu, intIdUtilisateur, intStatutVisible, booAfficheresultat from t_ccl_cas where intIdCas = @intIdCas
OPEN curs
FETCH NEXT FROM curs INTO @strTitre, @datCreation, @strAuteur, @intStatut, @strContenu, @intIdUtilisateur, @intStatutVisible, @booAfficheresultat
WHILE @@fetch_status = 0
BEGIN
/* Création du cas */
INSERT INTO t_ccl_cas (strTitre, datCreation, strAuteur, intStatut, strContenu, intIdUtilisateur, intStatutVisible, booAfficheresultat) VALUES (@strTitre, @datCreation, @strAuteur, @intStatut, @strContenu, @intIdUtilisateur, @intStatutVisible, @booAfficheresultat)
SET @intIdCasNouveau = @@IDENTITY
print 'cas créé, id=' + convert(varchar, @intIdCasNouveau)
/* Affectation des spécialités */
DECLARE curs2 CURSOR local fast_forward
FOR
select intIdSpecialite from t_ccl_cas_specialite where intIdCas = @intIdCas
OPEN curs2
FETCH NEXT FROM curs2 INTO @intIdSpecialite
WHILE @@fetch_status = 0
BEGIN
INSERT INTO t_ccl_cas_specialite (intIdCas, intIdSpecialite) VALUES (@intIdCasNouveau, @intIdSpecialite)
print 'spécialité affectée'
FETCH NEXT FROM curs2 INTO @intIdSpecialite
END
CLOSE curs2
/* Affectation des questions */
DECLARE curs3 CURSOR local fast_forward
FOR
select intIdQuestion, strIntitule, intNbReponses, intTypeQuestion, strExplication, booReponse, intOrdre, intIdUtilisateur, strIntroduction, booAffichePopup, booReponseMultiple from t_ccl_question where intIdCas = 192
OPEN curs3
FETCH NEXT FROM curs3 INTO @intIdQuestion, @strIntitule, @intNbReponses, @intTypeQuestion, @strExplication, @booReponse, @intOrdre, @intIdUtilisateur, @strIntroduction, @booAffichePopup, @booReponseMultiple
WHILE @@fetch_status = 0
BEGIN
INSERT INTO t_ccl_question (intIdCas, strIntitule, intNbReponses, intTypeQuestion, strExplication, booReponse, intOrdre, intIdUtilisateur, strIntroduction, booAffichePopup, booReponseMultiple) VALUES (@intIdCasNouveau, @strIntitule, @intNbReponses, @intTypeQuestion, @strExplication, @booReponse, @intOrdre, @intIdUtilisateur, @strIntroduction, @booAffichePopup, @booReponseMultiple)
SET @intIdQuestionNouveau = @@IDENTITY
print 'question créée, id=' + convert(varchar, @intIdQuestionNouveau)
/* Affectation des réponses */
DECLARE curs5 CURSOR local fast_forward
FOR select strIntitule, booValide, intNumReponse from t_ccl_reponse where intIdQuestion = @intIdQuestion
OPEN curs5
FETCH NEXT FROM curs5 INTO @strIntitule, @booValide, @intNumReponse
WHILE @@fetch_status = 0
BEGIN
INSERT INTO t_ccl_reponse (intIdQuestion, strIntitule, booValide, intNumReponse) VALUES (@intIdQuestionNouveau, @strIntitule, @booValide, @intNumReponse)
print 'réponse créée'
FETCH NEXT FROM curs5 INTO @strIntitule, @booValide, @intNumReponse
END
CLOSE curs5
FETCH NEXT FROM curs3 INTO @intIdQuestion, @strIntitule, @intNbReponses, @intTypeQuestion, @strExplication, @booReponse, @intOrdre, @intIdUtilisateur, @strIntroduction, @booAffichePopup, @booReponseMultiple
END
CLOSE curs3
FETCH NEXT FROM curs INTO @strTitre, @datCreation, @strAuteur, @intStatut, @strContenu, @intIdUtilisateur, @intStatutVisible, @booAfficheresultat
END
CLOSE curs |
Partager