You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

309 lines
6.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

\documentclass[a4paper,11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[a4paper,hmargin=20mm,vmargin=30mm]{geometry}%\usepackage{fullpage}
\usepackage{url}
\usepackage{comment}
\usepackage{fancyhdr}% fancy header
\usepackage{fancyvrb}
\fancypagestyle{monstyle}{
%\fancyhead{}
\renewcommand{\headrulewidth}{1pt}
%% %\renewcommand{\footrulewidth}{0.4pt}
% \fancyhead[LE]{\slshape \thepage/ \pageref{LastPage}}
%% \fancyhead[RO]{\slshape \thepage/ \pageref{LastPage}}
%\fancyhf{}
%\fancyhead[LE]{\slshape LE}
%\fancyhead[CE]{\slshape CE}
%\fancyhead[RE]{\slshape RE}
\fancyhead[LO]{\bfseries 2020-2021 BD PLS/SQL\rightmark}
%\fancyhead[CO]{\slshape APF}
\fancyhead[RO]{\bfseries ~\leftmark }
%% %\fancyfoot{}
% \fancyfoot[LE,RO]{}
\fancyfoot[CO,CE]{}%\slshape\thepage/\pageref{LastPage}}
%% %\fancyfoot[LO,RE]{\small\slshape \ddmmyyyydate version du \today}
}
% \pagestyle{fancy}
\usepackage{amsmath}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{exercice}{Exercice}
\pagestyle{monstyle}
\usepackage{amsmath}
\usepackage{amsthm}
\newcommand{\code}[1]{\texttt{#1}}
\begin{document}
\begin{center}
TP2
\end{center}
\begin{SaveVerbatim}{VerbEnv}
Catégorie : numéro libellé
Num. véhic. Immat. Couleur Modèle
XXXXX XX-9999-XX X...X X...X
XXXXX XX-9999-XX X...X X...X
XXXXX XX-9999-XX X...X X...X
\end{SaveVerbatim}
\begin{exercice} Afficher la liste des véhicules libres dune catégorie dont on saisit le numéro.
Laffichage se fera sous la forme :
\begin{center}
\fbox{\BUseVerbatim{VerbEnv}}
\end{center}
{\bf Cas derreur :}
\begin{itemize}
\item « catégorie inconnue »
\item « Pas de véhicules libres dans cette catégorie »
\end{itemize}
\end{exercice}
\begin{verbatim}
ORA-01001: verifier que le curseur est ouver
-- TEST
-- CAT3
-- VE005 ff-6000-za noire Picasso
-- CAT2
-- Pas de vehicule libre dans cette categorie
-- CAT7
-- Pas de vehicule libre dans cette categorie
DROP TABLE tligne;
CREATE TABLE tligne (ligne varchar2(300));
set echo off; set verify off; set feed off;
variable vcategorie char(4);
prompt Entrer le numero de la categorie :
accept vnocategorie
declare
dimmatriculation Tvehicule2017.immat%TYPE;
dnoveh Tvehicule2017.noveh%TYPE;
dcouleur Tvehicule2017.couleur%TYPE;
dmodele Tvehicule2017.modele%TYPE;
dcat number;
cursor r is select noveh, immat, couleur, modele from Tvehicule2017
where nocat='&vnocategorie' and noveh not in (select noveh from Tlocation2017)
order by noveh;
begin
select noveh, immat, couleur, modele into dnoveh, dimmatriculation, dcouleur, dmodele
from Tvehicule2017
where nocat='&vnocategorie' and noveh not in (select noveh from Tlocation2017)
order by noveh;
select count(nocat) into dcat from Tcategorie2017 where nocat='&vnocategorie';
if dcat = 0 then insert into tligne values ('categorie inconnu');
end if;
open r;
fetch r into dnoveh, dimmatriculation, dcouleur, dmodele;
while r%found
loop
insert into tligne values ( dnoveh ||' '||dimmatriculation||'
'||dcouleur||' '||dmodele);
fetch r into dnoveh, dimmatriculation, dcouleur, dmodele;
end loop;
close r;
exception
when no_data_found then
insert into tligne values ('Pas de vehicule libre dans cette categorie');
end;
.
/
select * from tligne;
set echo on; set verify on; set feed on;
\end{verbatim}
\begin{exercice}
Afficher la liste des locations en cours dun client dont le numéro
est saisi par l'utilisateur. La liste sera triée par catégorie puis
par numéro de véhicule. En fin de liste il faut afficher le nombre de
locations en cours du client.
\begin{SaveVerbatim}{exo2}
Propriétaire : numéro nom
Catégorie num vehic. Date début Modèle
XXXX XX-9999-XX 99-99-9999 X...X
XXXX XX-9999-XX 99-99-9999 X...X
XXXX XX-9999-XX 99-99-9999 X...X
Nombre de locations en cours : 99
\end{SaveVerbatim}
\begin{center}
\fbox{\BUseVerbatim{exo2}}
\end{center}
Remarque : le n° saisi doit correspondre à un n° existant dans
la base (ce cas derreur n'est pas trait\'e dans cette question).
{\bf Cas derreur :}
\begin{itemize}
\item « aucune location pour ce client »
\item « plusieurs locations en cours pour ce client » (cf un prochain
TP pour traiter ce problème)
\end{itemize}
\end{exercice}
\begin{verbatim}
-- TEST C001
-- VE001 VE001 30-JAN-17 clio 3
-- VE002 VE002 28-JAN-17 308
-- Nombre de locations en cours pour le client C001 est de 2
DROP TABLE tligne;
CREATE TABLE tligne (ligne varchar2(200));
set echo off; set verify off; set feed off;
variable vclient char(4);
prompt Entrer le numero du client:
accept vnoclient
declare
dnocat Tvehicule2017.nocat%TYPE;
dnoveh Tlocation2017.noveh%TYPE;
ddatedeb Tlocation2017.datedeb%TYPE;
dmodele Tvehicule2017.modele%TYPE;
dnombreloc number;
cursor r is
select nocat, Tlocation2017.noveh, datedeb, modele
from Tlocation2017, Tvehicule2017
where noclient='&vnoclient' and Tlocation2017.noveh= Tvehicule2017.noveh
order by nocat, noveh;
begin
open r;
fetch r into dnocat, dnoveh, ddatedeb, dmodele;
while r%found
loop
insert into tligne values (dnoveh||' '||dnoveh||' '||ddatedeb||' '||dmodele);
fetch r into dnocat, dnoveh, ddatedeb, dmodele;
end loop;
close r;
select count(noclient) into dnombreloc
from Tlocation2017
where noclient='&vnoclient';
insert into tligne values ('Nombre de locations en cours pour le client '||'&noclient'|
|' est de '||dnombreloc);
exception
when no_data_found then
insert into tligne values ('Pas de vehicule libre');
end;
.
/
select * from tligne;
set echo on; set verify on; set feed on;
\end{verbatim}
\begin{exercice}Afficher le nombre de véhicules par catégorie.
\begin{SaveVerbatim}{exo3}
Nombre de véhicules par catégorie
Catégorie nb de véhicules
XXXX 99
XXXX 99
\end{SaveVerbatim}
\begin{center}
\fbox{\BUseVerbatim{exo3}}
\end{center}
\end{exercice}
\begin{verbatim}
DROP TABLE tligne;
CREATE TABLE tligne (ligne varchar2(300));
set echo off; set verify off; set feed off;
declare
dnocat Tvehicule2017.nocat%TYPE;
dnbveh number;
cursor r is
select nocat, count(nocat)
from Tvehicule2017
group by nocat
order by nocat;
begin
open r;
fetch r into dnocat, dnbveh;
while r%found
loop
insert into tligne values (dnocat ||' '||dnbveh);
fetch r into dnocat, dnbveh;
end loop;
close r;
end;
.
/
select * from tligne;
set echo on; set verify on; set feed on;
\end{verbatim}
\end{document}