Prb with dbms_output.put_line - urgent
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Prb with dbms_output.put_line - urgent

  1. #1
    Join Date
    Sep 2009
    Posts
    6

    Prb with dbms_output.put_line - urgent

    HEY ALL,

    I am facing prb with the dbms_output.put_line.

    I am writing an SQL procedure and trying to get the output.
    My procedur works fine but the I have prb in displaying the output.

    Here is the problematic code snippet:

    FOR i in 1....lcount LOOP
    if(i=lcount) then
    dbms_output.put_line('The value is' || user_name);
    else
    dbms_output.put_line('The present value is' || user_name || 'and');
    END IF;
    END LOOP;

    Here user_name is a string.

    Now when I execute the procedure for one condition I get the output as:

    The present value is 'User' and
    The value is 'Answer'

    PL/SQL procedure executed succesfully.

    But I want the output as:

    The present value is 'User' and The value is 'Answer'

    Do anyone know how can I print the dbms.output line in one line instead of 2 seperate lines?
    I do not want the else part's dbms output line to print in the next line. I want it in the same line.

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    Quote Originally Posted by dbaliker View Post
    Do anyone know how can I print the dbms.output line in one line instead of 2 seperate lines?
    Yes. Issue a single dbms_output.put_line instead of two.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Sep 2009
    Posts
    6
    Hey thanks. But how will I do that?
    I have a condition that when it is inside if loop, I want a statement as 'The value is' and when it is inside else part I want it as 'The value is Usernmae and'. I do not want the 'and' appended for the last condition.
    Can you please tell me how I will do that?

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    Quote Originally Posted by dbaliker View Post
    Can you please tell me how I will do that?
    Let your internal logic build the string you want to spool out then, when you are ready issue a single dbms_output.put_line writing the string.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width