Guest User

Untitled

a guest
Jul 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. declare
  2. cursor get_states_and_cities(pId_country number) is
  3. select c.nm_country,
  4. s.nm_state,
  5. ct.nm_city
  6. from countries c,
  7. states s,
  8. cities ct
  9. where ct.id_state = s.id_state
  10. and s.id_country = c.id_country
  11. and c.id_country = pId_country;
  12.  
  13. type location_type is record(
  14. nm_country countries.nm_country%type,
  15. nm_state states.nm_state%type,
  16. nm_city cities.nm_city%type
  17. );
  18.  
  19. location location_type;
  20. begin
  21. open get_states_and_cities(1685);
  22. loop
  23. fetch get_states_and_cities into location;
  24. exit when location%notfound;
  25. dbms_output.put_line(location.nm_country || ' - ' || location.nm_state || ' - ' || location.nm_city);
  26. end loop;
  27. close get_states_and_cities;
  28. end;
Add Comment
Please, Sign In to add comment