2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

last statement of procedure after for loop is not working in pl sql

I have created following test procedure, where i am printing debug message, i fount that last statement of procedure after for loop is not working. why ?

in following case, i am not able to print debug message of third for loop, you can find result after procedure:

CREATE OR REPLACE PROCEDURE TEST_SCRIPT AS

BEGIN

  DBMS_OUTPUT.enable;

  DBMS_OUTPUT.PUT("-- Before for loop --");

  for rec in (

    SELECT sysdate FROM DUAL

  ) loop

  DBMS_OUTPUT.NEW_LINE();

  DBMS_OUTPUT.PUT("-- inside for loop --");

  end loop;

  DBMS_OUTPUT.NEW_LINE();

  DBMS_OUTPUT.PUT("-- after for loop --");

  for rec in (

    SELECT sysdate FROM DUAL

  ) loop

  DBMS_OUTPUT.NEW_LINE();

  DBMS_OUTPUT.PUT("-- second loop --");

  end loop;

  for rec in (

    SELECT sysdate FROM DUAL

  ) loop

  DBMS_OUTPUT.NEW_LINE();

  DBMS_OUTPUT.PUT("-- third loop --");

  end loop;

END TEST_SCRIPT;

result:

-- Before for loop --

-- inside for loop --

-- after for loop --

-- second loop --

Process exited.

userimage

try to use

DBMS_OUTPUT.PUT_LINE

instead of DBMS_OUTPUT.PUT

Answer is