1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
mhouri >create table countries(country_id number
2 ,country_name varchar2(30)
3 ,region_id number);
Table created.
mhouri >insert into countries values (1, 'Belgique',100);
1 row created.
mhouri >insert into countries values (2, 'France',200);
1 row created.
mhouri >insert into countries values (3, 'Qatar',300);
1 row created.
mhouri >commit;
Commit complete.
mhouri >CREATE OR REPLACE PROCEDURE p_get_country_info (p_country_id NUMBER)
2 IS
3 CURSOR c_get_countries
4 IS
5 SELECT country_id, country_name, region_id
6 FROM countries
7 WHERE country_id = p_country_id;
8
9 lr_countries countries%ROWTYPE;
10 BEGIN
11 FOR r_get_countries IN c_get_countries
12 LOOP
13 dbms_output.put_line ('country_id :' || r_get_countries.country_id);
14 dbms_output.put_line ('country_name :' || r_get_countries.country_name);
15 dbms_output.put_line ('country_region_id :' || r_get_countries.region_id);
16 END LOOP;
17 END;
18 /
Procedure created.
mhouri >set serveroutput on
mhouri >begin
2 p_get_country_info(1);
3 end;
4 /
country_id :1
country_name :Belgique
country_region_id :100
PL/SQL procedure successfully completed.
mhouri >spool off; |
Partager