oracle - How to fetch values from cursor into variables? -
i have problems fetching values cursor variables:
create or replace procedure projectinfo(num clubs.clubid%type) --identify variables p_cln clubs.clubname%type; p_projn projects.projectname%type; p_projnum number; p_taskn tasks.taskname%type; p_tasknum number; cursor cur select c.clubname, p.projectname, t.taskname clubs c join projects p on c.clubid=p.clubid join tasks t on t.projectid=p.projectid c.clubid=num; --i have checked above cursor , it's worked fine!!! begin p_projnum:=0; p_tasknum:=0; open cur; loop fetch cur p_cln,p_projn, p_taskn; dbms_output.put_line(p_cln|| ' ' ||p_projn|| ' ' || p_taskn); -- above command not print variable values!!! exit when cur%notfound; p_projnum:=p_projnum+1; dbms_output.put_line(' ************************ '); dbms_output.put_line(' club name : ' ||p_cln); dbms_output.put_line( ' project ' ||p_projnum|| ' ' || p_projn); loop p_tasknum:=p_tasknum+1; dbms_output.put_line('task: ' ||p_tasknum|| ' ' || p_taskn); fetch cur p_cln,p_projn, p_taskn; exit when cur%notfound; end loop; end loop; close cur; end projectinfo;
i have checked cursor , itdoes contain values need. programm compiles fine not print output!!!
what tool using run procedure? default, tools not allocate buffer dbms_output
write , not display written dbms_output
. that's why you'd never depend on dbms_output
real code.
if using sql*plus, need enable serveroutput
before executing procedure
sql> set serveroutput on; sql> exec projectinfo( <<some number>> );
if using gui, gui have way enable dbms_output
. different different applications. in sql developer, example, you'd need ensure dbms output
window visible, click green "plus sign" icon, , choose connection enable dbms_output
.
Comments
Post a Comment