Base de données
declare res number; resu varchar(100); begin resu := to_char (Tcamion.plusLourd2() ); dbms_output.put_line ('plus lourd : ' || resu); insert into result(r) values (resu) ; /* select * from result; */ end appel;
/
//camion.sql drop table ElementCharge; drop table Produit; drop table Charge; drop table Camion; drop type TelementCharge; drop type Tproduit; drop type Tcharge; drop type Tcamion;
create type Tcamion as object (noImmat varchar(10), poidsVide decimal(10), poidsMaxi decimal(10), static function plusLourd return varchar, member function poidsCamion return decimal )
/
create type Tcharge as object (noCharge decimal(10), dateLivraison date, poidsCharge decimal(10), camion ref Tcamion )
/
create type Tproduit as object (noproduit decimal(10), libelleProduit varchar(20) )
/
create type TelementCharge as object (charge ref Tcharge, produit ref Tproduit, quantite decimal(10) )
/
create table Camion of Tcamion (primary key (noImmat) ) storage (initial 16K)
/
create table Charge of Tcharge (primary key (noCharge), check (camion is not null), foreign key (camion) references Camion ) storage (initial 16K)
/
create table Produit of Tproduit (primary key (noProduit) ) storage (initial 16K)
/
create table ElementCharge of TelementCharge (check (charge is not null), check (produit is not null), foreign key (charge) references Charge, foreign key (produit) references Produit ) storage (initial 16K)
/
create or replace type body Tcamion as member function poidsCamion return decimal is poids decimal; begin select sum (c.poidsCharge) into poids from Charge c where c.camion.noImmat = self.noImmat; poids := nvl(poids,0) + self.poidsVide; return poids; end poidsCamion; static function plusLourd return varchar is numero Camion.noImmat%type; begin select c1.noImmat into numero