I have an upload page that inserts values from a text file into a table. Within the thest file i have a field called 'ID' the values in this field contain integers and values with both numbers and letters. As the values are inserted into the table I need to do a replace that replaces the letters with the number 1. example:
41ASTR234 becomes 411111234
My insert query looks like this:
<cfloop query="getTXT">
<cfquery name="products2" datasource="bbd">
INSERT INTO products
(
ProductID,
Status,
man,
model,
PriceRunner,
PriceGrabber,
InStock,
CategoryMain,
Category,
ManPartNo,
BriefDesc,
cost,
rrp,
saleprice,
image,
ingrams,
image2,
feedcategory
)
Values
(
'#getTXT.ID#',
'Normal',
<cfif getTXT.brand eq 'CISCO SYSTEMS'>'#Replace(getTXT.brand, "CISCO SYSTEMS", "Cisco", "ALL")#' <cfelse>'#Replace(getTXT.brand, "NETGEAR INC.", "Netgear", "ALL")#'</cfif>,
'#Replace(getTXT.title, ",", ";", "ALL")#',
'NO',
'NO',
'YES',
<cfif getTXT.majcat eq 'Display'>'#Replace(getTXT.majcat, "Display", "Monitors", "ALL")#'<cfelseif getTXT.brand eq 'CISCO SYSTEMS'>'#Replace(getTXT.majcat, "Communications & Networking", "Cisco", "ALL")#'<cfelseif getTXT.majcat eq 'Cables'>'#Replace(getTXT.majcat, "Cables", "Cabling", "ALL")#'<cfelse>'#Replace(getTXT.majcat, "&", "and", "ALL")#'</cfif>,
'#Replace(getTXT.mincat, "&", "and", "ALL")#',
'#getTXT.pnb#',
'#Replace(getTXT.shortdsc, ",", ";", "ALL")#',
'#getTXT.costprice#',
'0',
'#getTXT.saleprice#',
'#getTXT.imageurl#',
'Y',
'blank',
'none'
)
</cfquery>
</cfloop>
so int his example i'm looking at the destination field being 'productID' that must contain only integers and we are looking at the '#getTXT.id#' which must include the replace function.
Any thoughts,
Thanks in advance
Premium Content
You need an Expert Office subscription to comment.Start Free Trial