Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

xmltoQuery removing leading zero

New Here ,
Nov 07, 2012 Nov 07, 2012

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,

714
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 07, 2012 Nov 07, 2012

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

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 08, 2012 Nov 08, 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 08, 2012 Nov 08, 2012
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources