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



declare v_count number(8,3); v_sal scott.emp.sal%type := '&P_sal'; cursor cur_name ..

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

declare v_count number(8,3); v_sal scott.emp.sal%type := '&P_sal'; cursor cur_name ..

Answer / sai

First open the cursor and fetch the records then u get the
required output.

Is This Answer Correct ?    2 Yes 2 No

declare v_count number(8,3); v_sal scott.emp.sal%type := '&P_sal'; cursor cur_name ..

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

Post New Answer

More SQL PLSQL Interview Questions

what is a database lock ? : Sql dba

0 Answers  


What is error ora-12154: tns:could not resolve the connect identifier specified?

0 Answers  


I want to display the employees who have joined in last two months. (It should be executed randomly means If I execute the query in March it should display Jan and Feb joined employees. Same query if i execute in Feb, 2007 it should display dec, 2006 and jan 2007 joined employees.

15 Answers   Wipro,


Mention what does the hierarchical profiler does?

0 Answers  


Two Methods of retrieving SQL?

7 Answers   Atiric Software, Microsoft, Oracle, TCS, Wipro,






I have a Employee table with columns ename,eid,salary,deptno. How to retrieve sum of salary for each deptno?

8 Answers   L&T,


Is sql similar to python?

0 Answers  


what is blob? : Sql dba

0 Answers  


Why select is used in sql?

0 Answers  


What does trigger mean in slang?

0 Answers  


What is sql clause?

0 Answers  


What is pessimistic concurrency control? : Transact sql

0 Answers  


Categories