Skip to main content
Known Participant
November 7, 2012
Question

xmltoQuery removing leading zero

  • November 7, 2012
  • 1 reply
  • 796 views

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,

    This topic has been closed for replies.

    1 reply

    Inspiring
    November 7, 2012

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

    --

    Adam

    Known Participant
    November 8, 2012

    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>

    Inspiring
    November 8, 2012

    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