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

Thread: rpad(...,...,...)

  1. #1
    Join Date
    Jul 2001
    Posts
    334

    rpad(...,...,...)

    Hi All,

    Am trying to insert 50As if the column is null
    e.g

    select decode('','',rpad('',50,'A'),'') from dual


    Need help, above code is not working, any idea.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    You need the column name, compare:

    select decode(dummy,NULL,rpad(dummy,50,'A'),dummy) from dual;

    select decode(dummy,'X',rpad(dummy,50,'A'),dummy) from dual;

  3. #3
    Join Date
    Jul 2001
    Posts
    334
    Hi,
    Still not working,
    for example

    if dname is null then I need to add 5 As.

    select decode(dname,null,rpad(dname,5,'A') from dept;

    Thanks.

  4. #4
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    select decode(dname,null,rpad('A',5,'A'), dname) from dept;
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  5. #5
    Join Date
    Jul 2001
    Posts
    334
    Excellent jmodic, it works..

    Thanks

  6. #6
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Nvl(dname,'AAAAA') might be more intuitive.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  7. #7
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Nvl(dname,rpad('A',50,'A')) would save counting 50 of them. (Most probably wrongly if I were doing it).

  8. #8
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Is it "5", or "50"? Seems to be some confusion. if 50, then RPAD('A',50,'A') is indeed more robust.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

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