pl sql implicit cursor
FOR b IN (SELECT *
FROM sometable)
LOOP
<<do something b.somevalue>>
END LOOP;
pl sql implicit cursor
FOR b IN (SELECT *
FROM sometable)
LOOP
<<do something b.somevalue>>
END LOOP;
pl sql cursor
/*Is abit complex*/
set serveroutput on ;
Declare
departmentName departments.department_name %Type;
countryName countries.country_name%Type;
countryName2 countries.country_name%Type;
cursor info2 is
select countries.country_name from departments,countries,locations where departments.location_id=locations.location_id and locations.country_id=countries.country_id GROUP by countries.country_name;
cursor info is
select departments.department_name,countries.country_name from departments,countries,locations where departments.location_id=locations.location_id and locations.country_id=countries.country_id;
begin
for rec2 in info2
loop
countryName:= rec2.country_name;
dbms_output.put_line('Deparments in the ' || countryName ||' :' ||chr(13));
for rec in info
loop
departmentName:= rec.department_name;
countryName2:= rec.country_name;
if countryName2=countryName then
dbms_output.put_line(' '||departmentName);
end if;
end loop;
dbms_output.put_line('------------------------------------');
end loop;
end;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us