Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider f6c7070c rédigé par E214194U's avatar E214194U
Parcourir les fichiers

transfer iut2

parent db3c8b8d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 0 ajout et 194 suppressions
# `Compte Rendu du DS d'SQL dans un langage de programmation`
Alexandre Clénet / Groupe 2 / `i2c09a`
## Exercice 1 :
```sql
create or replace TRIGGER supprimer_étudiant after delete on etudiant
BEGIN
delete from souhait where numetudiant not in (select numetudiant from etudiant);
delete from affect_stage_etudiant where numetudiant not in (select numetudiant from etudiant);
END;
```
TEST :
```sql
delete from etudiant
where numetudiant=10;
```
1 ligne supprimé.
## Exercice 2 :
```sql
CREATE OR REPLACE TRIGGER maxsouhait AFTER
insert or update ON souhait
DECLARE
REC_etudiant etudiant%ROWTYPE;
BEGIN
Select * into REC_etudiant from etudiant e
where (select count(*) from souhait p where e.numetudiant=p.numetudiant)> 5 ;
RAISE_APPLICATION_ERROR (-20064,'viol de la règle : etudiant a trop de souhait');
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
WHEN TOO_MANY_ROWS THEN
RAISE_APPLICATION_ERROR ( -20065,'viol de la règle : plusieurs etudiant a trop de souhait' );
END;
```
TEST :
```sql
-- L'étudiant 1 a 4 souhait
insert into souhait VALUES (1,101); --ajoute un 5e souhait
insert into offre_stage VALUES (601,60,'z',100); --ajoute une offre
insert into souhait VALUES (1,601);-- ajoute un 6e souhait
```
Rapport d'erreur -
ORA-20064: viol de la règle : etudiant a trop de souhait
ORA-06512: à "I2C09A.MAXSOUHAIT", ligne 6
ORA-04088: erreur lors d'exécution du déclencheur 'I2C09A.MAXSOUHAIT'
## Exercice 3 :
Trigger 1 :
```sql
CREATE OR REPLACE TRIGGER remunmax AFTER
insert or update ON affect_stage_etudiant
DECLARE
REC_entreprise entreprise%ROWTYPE;
BEGIN
Select * into REC_entreprise from entreprise e
where (select sum(remuneration) from offre_stage t where e.nument=t.nument)*(select count(numetudiant) from affect_stage_etudiant a,offre_stage t where e.nument=t.nument and t.numoffre=a.numoffre)>0;
RAISE_APPLICATION_ERROR (-20074,'viol de la règle : remuneration maximale dépassé pour une entreprise');
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
WHEN TOO_MANY_ROWS THEN
RAISE_APPLICATION_ERROR ( -20075,'viol de la règle : remuneration maximale dépassé pour plusieurs entreprises' );
END;
```
TEST :
```sql
insert into offre_stage VALUES (203,20,'z',3000); --je mets une offre à 3000 (l'entreprise 20 dépense deja 940€)
insert into affect_stage_etudiant VALUES (2,203); --j'ajoute à l'entreprise un etudiant sur l'offre (on dépasse les 3500€)
```
Rapport d'erreur -
ORA-20075: viol de la règle : remuneration maximale dépassé pour plusieurs entreprises
ORA-06512: à "I2C09A.REMUNMAX", ligne 10
ORA-04088: erreur lors d'exécution du déclencheur 'I2C09A.REMUNMAX'
Trigger 2 :
```sql
CREATE OR REPLACE TRIGGER remunmax2 AFTER
insert or update ON offre_stage
DECLARE
REC_entreprise entreprise%ROWTYPE;
BEGIN
Select * into REC_entreprise from entreprise e
where (select sum(remuneration) from offre_stage t where e.nument=t.nument)*(select count(numetudiant) from affect_stage_etudiant a,offre_stage t where e.nument=t.nument and t.numoffre=a.numoffre)>0;
RAISE_APPLICATION_ERROR (-20074,'viol de la règle : remuneration maximale dépassé pour une entreprise');
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
WHEN TOO_MANY_ROWS THEN
RAISE_APPLICATION_ERROR ( -20075,'viol de la règle : remuneration maximale dépassé pour plusieurs entreprises' );
END;
```
TEST :
```sql
update offre_stage
set offre_stage.remuneration = 4000 where offre_stage.nument=20;
```
Rapport d'erreur -
ORA-20075: viol de la règle : remuneration maximale dépassé pour plusieurs entreprises
ORA-06512: à "I2C09A.REMUNMAX2", ligne 10
ORA-04088: erreur lors d'exécution du déclencheur 'I2C09A.REMUNMAX'
\ No newline at end of file
Fichier supprimé
Fichier supprimé
Fichier supprimé
# Default ignored files
/shelf/
/workspace.xml
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinCommonCompilerArguments">
<option name="apiVersion" value="1.6" />
<option name="languageVersion" value="1.6" />
</component>
</project>
\ No newline at end of file
<component name="libraryTable">
<library name="JarOracle-20221003">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../JarOracle-20221003/ojdbc8.jar!/" />
<root url="jar://$PROJECT_DIR$/../JarOracle-20221003/orai18n.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="KotlinJavaRuntime" type="repository">
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10" />
<CLASSES>
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.10/kotlin-stdlib-jdk8-1.6.10.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.6.10/kotlin-stdlib-1.6.10.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.6.10/kotlin-stdlib-common-1.6.10.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.10/kotlin-stdlib-jdk7-1.6.10.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.10/kotlin-stdlib-jdk8-1.6.10-javadoc.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.6.10/kotlin-stdlib-1.6.10-javadoc.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.6.10/kotlin-stdlib-common-1.6.10-javadoc.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.10/kotlin-stdlib-jdk7-1.6.10-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.6.10/kotlin-stdlib-jdk8-1.6.10-sources.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.6.10/kotlin-stdlib-1.6.10-sources.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.6.10/kotlin-stdlib-common-1.6.10-sources.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.6.10/kotlin-stdlib-jdk7-1.6.10-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="true" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/bdkotlin.iml" filepath="$PROJECT_DIR$/bdkotlin.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="JarOracle-20221003" level="project" />
</component>
</module>
\ No newline at end of file
Fichier supprimé
Fichier supprimé
Fichier supprimé
Fichier supprimé
Fichier supprimé
Fichier supprimé
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter