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....
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / sai
First open the cursor and fetch the records then u get the
required output.
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / debasis mohanty
First We Have To Open Cursor
Then We Use Any Loop For That.
(because number of rows selected if we use loop)
After that Condition.
So That We Get Appropriate Answer.
Thanks & Regards
Debasis
dmddebasismohanty183@gmail.com
08722140827
Is This Answer Correct ? | 0 Yes | 1 No |
What is the life of an sql statement?
Main diff between varray and nested tablea
how to get @@error and @@rowcount at the same time? : Sql dba
What are the types of records?
Why plvtab is considered as the easiest way to access the pl/sql table?
what is the sql query to display current date? : Sql dba
How can get second highest salary in sql?
Write a sql to print only character form the below string. @So&*CIE%$TE@GEN!@RAL
What is snowflake sql?
What are the different datatypes available in PL/SQL?
Write the alter statement to enable all the triggers on the t.students table.
How to test for null values?