declare
v_count number(8,3);
v_sal scott.emp.sal%type := '&P_sal';
cursor cur_name is select sal from scott.emp where sal
between (v_sal-100) and (v_sal +1000);
begin
v_count :=nvl(sql%rowcount ,0);
if v_count = 0 then
dbms_output.put_line('no records are fetch in the given sal
range');
else
dbms_output.put_line('There is/are '||to_char(v_count)||
' salaries are selected in the given range ');
end if;
end;

in the above programm .....for any sal range ....always it
shows the following message..

no records are fetch in the given sal range

please find the mistake and share with me...with thansk and
regards..sarao....

Answer Posted / rohit

declare
v_count number(8,3);
v_sal scott.emp.sal%type := &P_sal;
cursor cur_name is select sal from scott.emp where sal between (v_sal-100) and (v_sal +1000);
begin
for i in cur_name loop
v_count :=nvl(cur_name%rowcount ,0);
exit when cur_name%notfound;
end loop;
dbms_output.put_line(v_count);
if v_count = 0 then
dbms_output.put_line('no records are fetch in the given sal range');
else
dbms_output.put_line('There is/are '||to_char(v_count)|| ' salaries are selected in the given range');
end if;
end;

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of function "module procedure" in pl/sql?

880


What is delete command in sql?

758


What is parameter substitution in sql?

752


How do you know if a relationship is 2nf?

687


Why we use cross join?

701






what is a constraint? Tell me about its various levels. : Sql dba

735


what are the nonstandard string types? : Sql dba

803


What plvcmt and plvrb does in pl/sql?

1058


how can we submit a form without a submit button? : Sql dba

721


Is sql an operating system?

719


what are the differences between binary and varbinary? : Sql dba

716


Explain what is sql?

825


What is the difference between row level and statement level trigger?

721


What are the parameter modes supported by pl/sql?

729


What is difference between mysql and postgresql?

703