Prevent oracle suppresses the leading zero

Hi guys,
What is the best way to prevent oracle from suppressing leading 0 while convert a number to char. I am using Release 11.2.0.1.0.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select to_char(0.01) from dual;
TO_
.01I can achieve this by using decode, for example:
SQL> select decode(instr(to_char(0.01), '.'),
  2                1,
  3                '0' || to_char(0.01),
  4                to_char(0.01)) val
  5    from dual;
VAL
0.01
SQL>But it doesn't look very pretty, is there a better way to do this please? Please note my data is mixed with values with or without decimal places. When the value is greater equal than 1, i want to have the output as same as to_char(val), the padding zero only applies to when the value is between 0 to 1. Many thanks.
Best regards,
Pete

Many thanks Justin, but it doesn;t give quite what i want
SQL> select to_char(1, '0.99') col from dual;
COL
1.00
SQL>Please note my data is mixed with or without decimal places, for example value 123, i just want to show 123, NOT 123.00 instead. At the moment i am using decode to do this as:
SQL> select decode(instr(to_char(123), '.'),
  2                1,
  3                '0' || to_char(123),
  4                to_char(123)) val
  5    from dual;
VAL
123
SQL>It works but it looks ugly to me, I wonder is there a better way to do this please?
Cheers,
Pete

Similar Messages

  • How to suppress the leading zeros , -ve sign in scripts

    Hi all,
    I was asked to suppress the leading zeros in a field while using a script.
    also how to suppress the negative sign in the scripts.
    Regards,
    Saroja.

    hi Saroja,
    <u>Sign</u>
    &ITCDP-TDULPOS& -> 100.00-
    &ITCDP-TDULPOS(S)& -> 100.00
    <u>zero</u>
    &DAY& -> 01
    &DAY(Z)& -> 1
    Hope this helps,
    Sajan Joseph.

  • The leading zeros are removing from Number field

    Hi,
    How can i keep the leading Zeros in the number field. For eg, when validating the field, 00123 becomes 123, how to prevent it,
    Thanks in advance

    Hi
    I tried with LPAD(:numberfield,5,'0') in the validate field, but it is not working, I am getting the error , it is not a procedure....., I working with Forms 10g
    Thanks in advance

  • Truncating the leading zeros

    hi,
    Could anybody pls tell me how do i truncate the leading zeros in the incoming file structure.
    Thanks,
    Chinna

    Hi,
    Check this thread, i laready answered it there.
    Suppressing leading zeroes during mapping
    For you i pasting the solution here.
    Write a UDF like this ..
    public class test {
    public static void main(String[] args) {
    System.out.println(args[0].replaceAll("^0*",""));
    Also you can use XSLT for this.
    Try the XPath function number($string) in your XSLT and see if it does what you want. Since it turns any XPath object into a number, the leading zeros won't appear.
    Use it ike this
    <xsl:variable name="a">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of select="EVENT/ContactPhone"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:template name="removeLeadingZeros">
    <xsl:param name="phone"/>
    <xsl:message>
    <xsl:value-of select="$phone"/>
    </xsl:message>
    <xsl:choose>
    <xsl:when test="starts-with($phone,'0')">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of
    select="substring-after($phone,'0' )"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$phone"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Regards
    Aashish Sinha
    PS : Reward Point if Helpful

  • Remove the leading Zero from the Query output in SAP BW ?

    Hi
    Experts,
    Vendor Number loaded  as   (0000010076) from R/3 to SAP BW.
    How to remove  Prefix  of Zero for  the Vendor Number(0000010076)  from Quey outpt.
    Regards.
    ASIT

    Hi,
    Please check out this thread.
    Remove leading zeros
    Also check if there is any conversion routine used for that particular infoobject.
    If ALPHA conversion is selected for your infoobject then it will automatically take away the leading zeros at query level.
    Regards,
    AL
    Edited by: AL1112 on Sep 16, 2011 9:15 AM

  • How can we put the leading zeros for the extract file.

    hello experts..
           Iam extracting values from one ztable in this for one filed length will be 2, for this field i need leading zero s at the time of extract... please help me....

    Hi,
    Declare the field as NUMC data type, automatically you will get the leading zeroes.
    Regards,
    Subramanian

  • How can I remove the leading zeros on jpg files?

    I'm looking for a way to remove the leading zeros on over 1000 jpg files, without changing the remaining digits in the file name. Is there some automated "batch" script?
    i.e going from 003405607.jpg  to  3405607.jpg

    You could write an AppleScript. but it will be easier to get and use a third-party file renaming utility. I use the freeware NameChanger which works quite well.
    https://www.macupdate.com/app/mac/21516/namechanger
    Regards.

  • How to maintain the leading zeros

    Hi all,
    I need help on this.
    I have field KNB1-KUNNR its real value for example is 0000000001,so there is leading zeros,but then everytime the program output the report leading zeros are removed. I need to display the leading zeros as is.
    By the way KNB1-KUNNR is declared as knb1-kunnr LIKE knb1-kunnr.
    thanks!

    Hi..
    Use this code for adding leading zeros for a particular field.
           CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
               input         =  p_kunnr
            IMPORTING
              OUTPUT     = p_kunnr.
    Use this code for removing leading zeros for a particular field.
           CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
             EXPORTING
               input         =  p_kunnr
            IMPORTING
              OUTPUT     = p_kunnr.

  • Document Templates in MS Word - how to cut the leading zeroes in number

    Hello CRM gurus !
    We use document templates in MS Word but have the document number printed with the leading zeroes.
    example we have now:
    0005000681
    example we want to have:
    5000681
    Question - how to do that?
    Is that in standard? The document number is the ObjectID tag as far as I know. Do I need to create another tag?
    Or may be just call a function? Do I need to change my current Web Service Tool? Is that some extra ABAP to be inserted?
    Thank you very much.

    Hi,
    have you tried to use this function call to delete de leading zeros?:
         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
             input  = value
           IMPORTING
             output = value.
    Best regards
    Manfred

  • Losing the leading zero in binary values

    Hi all,
    I�m currently creating some basic examples of bitwise operations and I�ve just noticed that I�m losing the leadnig zero of a binary value ( e.g.
    decimal 1 (expecting to see bin of 0001) is manifesting as 1
    decimal 16 (expecting to see bin of 00010000) is manifesting as 10000
    below is a full example
    import static java.lang.Integer.*;
    public class BitExample {
    public static void main(String[] args) {   
    System.out.println(
         toBinaryString(0x1) + '\n' +
         toBinaryString(0x16) + '\n' +
         toBinaryString(0x6a) + '\n' +
         toBinaryString(0x80)
    I can see I�m missing something, but not sure what. Can you help?
    Many Thanks
    Giles

    which obviously returns a very different resultNo it does not ... let's translate the example to decimal (with additions instead of bitwise operations, but that doesn't change anything:
    1234 +
    0001
    1235and
    1234 +
    1
    1235both notations are correct, aren't they? Now the second one doesn't look so nice (and usually the 1 should be right-aligned to be easily readable, but it isn't wrong, because of this.
    The same is true for binary operations. The problem is, that while learning bitwise operations it's easier to unserstand if you always write the leading zero (as you do in your example).

  • The leading zero in serial number..

    Hi all,
    Does anyone happen to know how to stop SAP from erasing the leading zero when entering a Serial number. I'm using profile 0003 (standard) and when a GR is posted the leading zeros are removed?
    Any help would be greatly appreciated.
    Best regards
    Begüm A.

    In the Standard SAP system, it is not possible to stop it from truncated the leading zeros.
    But if you are using  ECC6.0 and using Industrial Solutions, you may use the modification
    introduced by note 198285 to achieve this functionality.

  • Not to loose the leading zeroes

    Hi ,
    We are passing a data in table to the application server
    I have a variable zipcode in the table
    it is described as
    final_tab-zip   = p0006-pstlz(5).
    "zip is decalred as zip(5)
    Now I am passing the table as comma delimited file to application server.
    The problem is in the process..we are loosing the leading zeroes..
    if say zip is 08801..
    we see it as 8801...
    How can we preserve the leading zeroes when we transfer the data..
    Any change need to be done while decalration or transfer..
    Thank you.

    I am moving the field to the string and passing it to the file
    code is like this
    LOOP AT final_tab.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE pm_tab TO <fs>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          IF sy-index EQ 22.
            IF <fs> NE space.
              CONCATENATE string <fs> INTO string.
            ENDIF.
          ELSEIF sy-index EQ 1.
            IF <fs> EQ space.
              MOVE ',' TO string.
            ELSE.
              CONCATENATE string <fs> ',' INTO string.
            ENDIF.
          ELSE.
            IF <fs> EQ space.
              CONCATENATE string ',' INTO string.
            ELSE.
              CONCATENATE string <fs> ',' INTO string.
            ENDIF.
          ENDIF.
        ENDDO.
        APPEND string TO itab .
        CLEAR  string.
      ENDLOOP.
    Edited by: KUMAR BOJEDLA on Sep 5, 2008 11:10 AM

  • Need to strip the leading ZERO using ABAP code.

    Hi Friends,
    I got a situation where i got customer number called 011. I need to write an ABAP in Transformation to strip the leading ZERO , 11 should be posted to the master data attribute. could you help me in the logic pls.
    Thanks in advance,

    hi friends, i got a prob again, as i mentioned if i got 0 as prefix its deleting but if any 3 digit is comming it's converting in to 2 digit, as i mentioned if the prefix is 0(zero) then only i need to delete the zero.
    Is there any other solution for this..
    thansk in advance.

  • Is there a way to remove the leading zero from the 24 hour time display in iOS8?

    In the previous versions of iOS, the 24 hour time format for some regions dropped the leading zero from single digit hours: 1:23 for example.
    In iOS8, it appears that once 24 hour time format is toggled, the time is always displayed as four numbers: 01:23 for example.
    Is there a way to revert to this older format without leading zeroes?

    Yes, a colleague of mine was able to figure it out. Just double-click the chapter title in the .aggr project. It places it into edit mode and allows you to remove the ".swf" extension as well as make any other changes to the name that you want. It's so easy now that we know how to do it, but it was tricky to figure out since the chapter list does not appear editable at first.

  • EAN values truncationg the leading zeroes

    Hi experts,
    I have created two new EAN category for one category accepts one leading zeroes another category accepts two leading zeroes.
    In the material master i am trying to enter the same EAN values with different unit of measure system accepts the EAN value for one UOM and when i am trying to enter the same value for another UOM with two leading zeroes the leading zeroes are truncating.I can see the below warning message.When i press enter the leading zeroes are truncated.
    _EAN already used for unit of measure EA of this material_
    Please help me how to solve the issue.

    i guess this is coming because you have already mentioned the EAN no in one material amster and the data is maintained at client level so system is not allowing redundntcy

Maybe you are looking for

  • Down payment request on asset code(F-47)

    sirs, why cant we create down payment request for po's raised against asset code?? transaction code is f-47 if possible what is the setting to be done. mail to [email protected] regards suresh

  • After update to Safari 5.1 No cursor in Fishville

    I have cursor issues While playing the Fishville game on Facebook or Yahoo. Once the game loads my cursor disappears. I thinks its a browser issue but not sure how to resolve it. I tried the game in both Firefox and Opera and the cursor works fine. I

  • Help please: Refreshing a window

    Hello, I would like to refresh a window so I have try tell application "Finder" to update folder "My folder" of desktop end try It compiles but does not work, I have to do this: try tell application "Finder" to close folder "My folder" of desktop tel

  • Normal Report output to SAP Inbox

    Hi Gurus,               I have written a normal report,which gives some output when I execute it. Now my job is to run this report program in background for every month end. I know how to schedule this job. But how to get/store the output of that rep

  • Error in MOVE-CORRESPONDING  statement

    Hi all, I am facing issue in move-corresponding statement. Form: FORM get_first_data USING   it_lifnr TYPE ty_lifnr                              it_prdha TYPE ty_prdha                              it_matnr TYPE ty_matnr                              c