Adding a "0" to my column
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Adding a "0" to my column

  1. #1
    Join Date
    Aug 2000
    Posts
    29
    I am trying to add a zero "0" to the front of my data
    and am having trouble accomplishing this

    I am trying to make the column look like this;



    BEFORE AFTER

    DEED DEED
    122899 122899
    122899 122899
    20785 020785
    61695 061695
    61695 061695
    42087 042087
    111194 111194

    I tried using the LPAD function to no avail
    can anybody help me?
    scotta
    J.Scott Adams

  2. #2
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    If the column is of NUMBER type then the "0" preceeding 0s are truncated.

    Check to make sure that the column type is not of NUMBER
    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  3. #3
    Join Date
    Aug 2000
    Posts
    29
    sorry I forgot to add this
    It is a varchar2 datatype
    J.Scott Adams

  4. #4
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Here is an example:

    SQL>create table data(num VARCHAR2(10));

    SQL>insert into data values (LPAD('1029',10,'0'));

    SQL>select * from data;

    NUM
    ==========
    0000001029


    SQL>insert into data values ('384');

    SQL> update data
    2 set num = LPAD(num,10,'0')
    3 where num = '384';

    1 row updated.

    SQL> select * from data;

    NUM
    ==========
    0000001029
    0000000384


    Hope this would clear your doubts. For detail check your LPAD syntax.

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


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