Académique Documents
Professionnel Documents
Culture Documents
LAZAR ADNANE
TP 3
4-
Création de base de donne
create database DB_ligne_commande
a- Création des tables :
create table produit (
num_prod int primary key identity(1,1),
libelle varchar (50),
pu_prod real ,
qte_stock int ,
s_min int ,
s_max int
);
insert
into commande
values
('2017-01-02'),('2017-03-10'),('2017-12-01'),('2017-12-12'),('2017-01-03'),('2017-03-
30')
b-
Declare @Montant decimal
Set @Montant=(
Select Sum(pu_prod*qte_stock)
from commande C, produit P, lignecommande LC
where C.num_cmd=LC.num_cmd and LC.num_prod=P.num_prod and
C.num_cmd=5)
If @Montant is null Begin
Print 'Cette Commande n''existe pas ' Return
End
if @Montant <=10000 Print 'Commande Normale'
Else
Print 'Commande Spéciale'
c-
6- Procédure stockées :
Exercice 1 :
a/ la liste des produits et leur libelle
create procedure affichage
as
select num_prod , libelle from produit
exec affichage
exec affichage2
exec affichage
Exercice 2 :
Créer une base de nom Exe2 :
create database Exercice2
- les tables mouvement ,produitfini et fournisseur :
créer la table produitfini
create table produitfini(
cod_prod_fini int primary key,
nom varchar(50),
qtestock int,
)
exec pro1
exec pro2
exec pro4
7- les fonctions :
Exercice :
go
select * from etat_cmde(1,5)