DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: Right Justify

  1. #1
    Join Date
    Jan 2001
    Posts
    515

    Right Justify

    I am using the utl_file package to create a file. I have a variable

    v_amt char(200);

    I want to make an amount a character and then put it into the above field.

    v_amt := to_char(100);

    Now I want this amount to be right justified with 197 spaces in front of it. It is coming out as 100 with 197 spaces after it. Is there a function to right justify a string??

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    LPAD()
    Jeff Hunter

  3. #3
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    The simplest is probably:
    v_amt := lpad(to_char(100),200,' ');

    Perhaps this could work (I've no idea if there is a limit on the size of a format model):
    v_amt := to_char(100, '999 . . . 999');
    where there are 199 9's. See: http://www.csee.umbc.edu/help/oracle.../ch2.htm#34597

    Which begs the question - WHY?

  4. #4
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by DaPi
    Which begs the question - WHY?
    I've learned to not ask WHY? The answer is going to be something like "So it shows up on a report and the decimals line up" or "so it will sort in the right order"...
    Jeff Hunter

  5. #5
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Originally posted by marist89
    The answer is going to be something like "So it shows up on a report ...
    This should guarantee that it doesn't show up on the report - the least sig digits being about 60 postions to right of the RH margin!

  6. #6
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    except in legal landscape at Courier 2
    Jeff Hunter

  7. #7
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    My IBM ruler goes from 1 to 132 - and as far as I'm concerned that is it!
    Last edited by DaPi; 01-06-2004 at 10:11 AM.

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