0% found this document useful (0 votes)
24 views1 page

SQL

This document contains a PL/SQL script that queries an employee database to retrieve employee IDs, names, and total sales amounts and outputs the results. It declares variables, opens a cursor to run a SQL query joining multiple tables, fetches the results into variables, and outputs the formatted data in a loop.

Uploaded by

aymane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

SQL

This document contains a PL/SQL script that queries an employee database to retrieve employee IDs, names, and total sales amounts and outputs the results. It declares variables, opens a cursor to run a SQL query joining multiple tables, fetches the results into variables, and outputs the formatted data in a loop.

Uploaded by

aymane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

set serveroutput on;

declare
Nemp employes.idemploye%type;
NomEmp employes.nom%type;
type tab is table of float
index by binary_integer;
T tab;
ce float;
i integer;
s float;
cursor cur is
select employes.idemploye,employes.nom,SUM(Prixunitaire*Quantite*(1-Remise/100))
as CA from employes,produits,lignecommandes,commandes
where employes.idemploye=commandes.IDEMPLOYE
and commandes.idcommande=lignecommandes.idcommande
and lignecommandes.idproduit=produits.idproduit
group by (employes.idemploye,employes.nom);
begin
open cur;

dbms_output.put_line( 'Nemp'||' '||' NomEmp'||' '||'ca'||' ' ||'com');


fetch cur into Nemp,NomEmp,ce;
T(0):=montant(ce);
Dbms_Output.Put_Line(To_Char(Nemp,
999999)||'|'||NomEmp||'|'||To_Char(ce,
999999.99)||'|'||to_char(T(0), 99999999.99));
while cur%found loop
fetch cur into Nemp,NomEmp,ce;
i:=1;
T(i):=montant(ce);
Dbms_Output.Put_Line(To_Char(Nemp,
999999)||'|'||NomEmp||'|'||To_Char(ce,
999999.99)||'|'||to_char(T(i), 99999999.99));
i:=i+1;
end loop;
close cur;
end;

You might also like