3 Replies Latest reply on Nov 8, 2012 8:24 AM by Adam Cameron.

    xmltoQuery removing leading zero

    thnguyen

      Hi,

      I have a function that takes in a raw xml and covert to query.  The problem is any leading zeroes are gone.  For example, 000123 will become 123.  Is there any way or function in CF that will stop from removing leading zeroes?

       

      Thanks,

        • 1. Re: xmltoQuery removing leading zero
          Adam Cameron. Level 5

          Without having any idea what your code is, it's difficult to say too much that's meaningful.

           

          --

          Adam

          • 2. Re: xmltoQuery removing leading zero
            thnguyen Level 1

            Oh, sorry.  It's not the XML to Query problem but it's the cfquery problem.  When I cfdump the data, it shows 000123, but when I use <cfquery> to insert the data into a dabase, it strips the leading zeroes and in the db table it shows only 123.  Is there a function or something to prevent this?

             

             

            <cfoutput query="get_xml_data">
            
            <cfquery name="test" datasource="db">
                 INSERT INTO table (id, name)
                 VALUES (#get_xml_data.id#, #get_xml_data.name#)
            </cfquery>
            
            </cfoutput>
            
            • 3. Re: xmltoQuery removing leading zero
              Adam Cameron. Level 5

              How do you know it's the <cfquery> and not the DB?  I'm not saying it's not but have you proven it's a problem on the CF end?  The way to approach it will differ depending on what the story is.

               

              What datatype is the "name" column?

               

              Also: make sure to always use <cfqueryparam> on your dynamic values, rather than hard-coding them in your SQL string.

               

              --

              Adam