Copy link to clipboard
Copied
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,
Copy link to clipboard
Copied
Without having any idea what your code is, it's difficult to say too much that's meaningful.
--
Adam
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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