Results 1 to 6 of 6

Thread: how to store leading zeros in an integer field

  1. #1
    Join Date
    Nov 2008
    Posts
    1

    how to store leading zeros in an integer field

    Is there a way to store leading zeros in an integer field. I cannot change field name to a char field at this stage due to the external application restriction.
    At present 051 is stored as 51

    Thanks in advance

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can't, you can pad left 0s when you select from the table.

  3. #3
    Join Date
    Nov 2008
    Posts
    3

    Smile how to store leading 0's in a number

    Oracle doesnot allow to store leading 0's in the number. To overcome this problem, we can use SQL*plus environment command to see the same.

    example

    SQL> column sal format 09999.99
    sql> select sal from emp;

  4. #4
    Join Date
    Nov 2008
    Posts
    3

    Smile how to store leading 0's in a number

    SQL> column sal format 09999.99
    SQL> select sal from emp;

  5. #5
    Join Date
    Dec 2008
    Posts
    4

    if you can... change the datatype

    use an expression to change the datatype to varchar2 and use the lpad or rpad functionality

  6. #6
    Join Date
    Dec 2008
    Posts
    4
    sorry for the previous reply. obvoiusly not what you can do.

Posting Permissions

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