Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why cursor with fetch doesnt thrown to Many row exceptions

kparthiAug 11 2015 — edited Aug 11 2015

CREATE TABLE plch_memes

 

(

 

   meme_id       INTEGER,

 

   title         VARCHAR2 (100),

 

   description   VARCHAR2 (4000)

 

)

 

/

 

 

BEGIN

 

   INSERT INTO plch_memes

 

           VALUES (

 

     1,

 

     'Cats doing somersaults',

 

     'When that cat flips, the world flips with it.');

 

 

   INSERT INTO plch_memes

 

           VALUES (

 

     1,

 

     'Cats being the boss',

 

     'Who really “owns” whom?');

 

 

   COMMIT;

 

END;

 

/

 

 

 

CREATE OR REPLACE FUNCTION plch_meme_title (

 

   meme_id_in   IN plch_memes.meme_id%TYPE)

 

   RETURN VARCHAR2

 

IS

 

   CURSOR title_cur

 

   IS

 

      SELECT title

 

        FROM plch_memes

 

       --WHERE meme_id = meme_id_in

 

       ;

 

 

   l_return   plch_memes.title%TYPE;

 

BEGIN

 

   OPEN title_cur;

 

 

   FETCH title_cur INTO l_return;

 

 

   CLOSE title_cur;

 

 

   RETURN l_return;

 

END;

 

/

 

 

BEGIN

 

   DBMS_OUTPUT.put_Line (plch_meme_title (1));

 

END;

 

/

Calling the Function should throw  Two Many row exception ? . Why fetch doesn't throw it

This post has been answered by John Stegeman on Aug 11 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 8 2015
Added on Aug 11 2015
8 comments
523 views