MyTetra Share
Делитесь знаниями!
Country name по id локации
Время создания: 05.11.2017 09:28
Раздел: PL/SQL - Задачник - CURSORS - Параметризованный курсор
Запись: xintrea/mytetra_db_mcold/master/base/1509863315qwy2l1wbm6/text.html на raw.githubusercontent.com

1. Создать функцию возвращающую курсор countries по location_id

2. Вывести имя country_name по полученному значению country_name строки


create or replace function dep_from_loc_id(

loc_id integer)

return sys_refcursor

is

l_return sys_refcursor;

begin

open l_return for

select *

from locations l

where l.location_id = loc_id;

return l_return;

end;


declare

loc_cur sys_refcursor;

n_loc_id integer;

c_id countries.country_id%TYPE;

c_name countries.country_name%TYPE;

rec_loc locations%ROWTYPE;

cursor c_country(c_id countries.country_id%TYPE) is

select c.country_name

from countries c

where c.country_id = c_id;

begin

n_loc_id := 1700;

loc_cur := dep_from_loc_id(n_loc_id);

fetch loc_cur into rec_loc;

c_id := rec_loc.country_id;

open c_country(c_id);

fetch c_country into c_name;

close c_country;

dbms_output.put_line(c_name);

end;



 
MyTetra Share v.0.59
Яндекс индекс цитирования