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

How do I know if I have sql express or standard?

604


What are its different types of dbms?

542


What are sql queries used for?

536


Is primary key clustered or nonclustered?

568


How do I make my sql query run faster?

470






How to take user input in pl sql?

705


What are the advantages of pl sql?

607


What is null in pl/sql?

626


Can we use view in stored procedure?

510


what is a database lock ? : Sql dba

594


Can you call pl/sql package functions from within a fast formula?

564


What is difference between ms sql and mysql?

478


What is offset in sql query?

598


What is a clob in sql?

569


What are different methods to trace the pl/sql code?

544