Home » SQL & PL/SQL » SQL & PL/SQL » no output shown
no output shown [message #614777] Tue, 27 May 2014 02:35 Go to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Hi,

why it is not displayed any output's ?
SQL> set serveroutput on
SQL> DECLARE
  2     CURSOR c1 (dpno emp.deptno%TYPE)
  3     IS
  4        SELECT *
  5          FROM emp
  6         WHERE deptno = dpno;
  7     i   c1%ROWTYPE;
  8     dpno emp.deptno%TYPE;
  9  BEGIN
 10     OPEN c1(dpno);
 11     LOOP
 12        FETCH c1
 13         INTO i;
 14        EXIT WHEN c1%NOTFOUND;
 15        DBMS_OUTPUT.put_line (c1%ROWCOUNT);
 16     END LOOP;
 17     CLOSE c1;
 18  END;
 19  /

PL/SQL procedure successfully completed.

SQL> 
Re: no output shown [message #614779 is a reply to message #614777] Tue, 27 May 2014 02:36 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You never pass anything to DPNO, so cursor returns nothing, so you display nothing.
Re: no output shown [message #614780 is a reply to message #614779] Tue, 27 May 2014 02:45 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
You never pass anything to DPNO, so cursor returns nothing, so you display nothing.


Yes you are correct and i have used same code where i posted before and my requirement is implicitly take the deptno and display the total counts


i added below line in,then why i am not getting Hai on the output..
FETCH c1 INTO i;
      EXIT WHEN c1%NOTFOUND;
      DBMS_OUTPUT.put_line (c1%ROWCOUNT);
      DBMS_OUTPUT.put_line ('Hai'); --->This!
   END LOOP;
Re: no output shown [message #614782 is a reply to message #614780] Tue, 27 May 2014 02:48 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Yes must pass the dpno(parameter) and i want if the record count=0 then display as no records for this number we say as deptno 40.

I am sorry Littlefoot..

Thanks

[Updated on: Tue, 27 May 2014 02:49]

Report message to a moderator

Re: no output shown [message #614783 is a reply to message #614780] Tue, 27 May 2014 02:52 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
mist598 wrote on Tue, 27 May 2014 13:15
i added below line in,then why i am not getting Hai on the output..
FETCH c1 INTO i;
      EXIT WHEN c1%NOTFOUND;
      DBMS_OUTPUT.put_line (c1%ROWCOUNT);
      DBMS_OUTPUT.put_line ('Hai'); --->This!
   END LOOP;


There are no records to fetch. Hence, it comes out of loop when %NOTFOUND is true. So, it never goes to dbms_output line.
Previous Topic: ORA-8177 when execute procedure from forms10g
Next Topic: Read Binary Format File
Goto Forum:
  


Current Time: Thu Apr 25 14:37:43 CDT 2024