I am new to sql so i need help in understanding this.
I have 3 tables :-
Table 1 :- employee no.
employee name
person_id
Table 2 :- Contact no.
person_id
Table 3 :- Address
person_id
I tried to make a package and use a procedure to define a cursor. now i want to display the contact no ,address and emp number from the tables using joins. i have applied the join condition but am not able to understand how to display the result.
Package body
create or replace package pacakge_name
as
procedure procedure_name
declare
cursor cur_name is select * from table1 join table2 on table1.person_id=table2.person_id join table 3 on table1.person_idd=table3.id;
var_curname cur_name%rowtype;
begin
open cur_name;
loop
fetch cur_name into var_curname
exit
when cur_name%NOTFOUND;
end loop;
close cur_name;
end;
for displaying result to console you have to
dbms_output.put_line(var_curname.fieldname);this will be your cursor query:
so your dbms_output.put_line will be