Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

CREATE OR REPLACE PROCEDURE DEPXPAIS

is

CURSOR C IS select country_name as pais, count(department_id) as Num_dep

from locations l join departments d

on (d.location_id=l.location_id)

join countries c

on (l.country_id = c.country_id)

group by country_name

order by count(department_id) DESC;

type reg is record(

pais countries.country_name%type,

Num_dep number );

r reg;

BEGIN

OPEN C;

LOOP

FETCH C INTO R;

EXIT WHEN C%ROWCOUNT=4;

DBMS_OUTPUT.PUT_LINE(R.pais || '-' || R.Num_dep);

END LOOP;

CLOSE C;

END;
begin depxpais;

end;

You might also like