CFQUERY not updating when reading from XML

Discussion in 'Programming' started by vivid., Oct 30, 2009.

  1. #1
    Hi There,

    Have an XML file which is being read fine, but just dose not want to update file.

    <cffile action="read" file="NOT NEEDED IN THREAD" variable="csvfile3" > 
    <!--- loop through the CSV-TXT file on line breaks and insert into database ---> 
    <cfset request.currentrow = 0>
    <cfloop index="row" list="#csvfile3#" delimiters="#chr(10)##chr(13)#" > 
    	 
    	  <!--- replace empty columns in the middle of the string with a space --->
    	 <cfset row = replace(row, ",,", ", ,", "all")>
    	 <!--- repeat replace to catch all of the empty columns --->
    	 <cfset row = replace(row, ",,", ", ,", "all")>
    	 <!--- catch empty columns at beginning and end --->
    	 <cfset row = chr(32) & row & chr(32)>
     	
    	 
     
    	 <!--- add your insert here --->
    	 <cfoutput>
         
         <cfif #request.currentrow# Neq 0>
    	    <!--- trim the extra spaces --->
    		
            <cfset request.newList = listChangeDelims(#trim(listgetAt(row, 6))#,'','"')>
    
           <Cfset request.price = #request.newList#  * 1.15><b>#LSCurrencyFormat(request.price, "none")#</b>,
           
            
            
            <cfset request.stockcode = '#listChangeDelims(listgetAt(row, 1),'','"')#' >
           
    	   
    	   <cfif #Left(request.stockcode, 1)# eq 0>
            
           <cfset request.stockcode = '#RemoveChars(request.stockcode,1,1)#' >
           
           </cfif>
            
            <cfset request.webstock = '#listChangeDelims(listgetAt(row, 2),'','"')#'>
            <cfif request.webstock eq ''>
            <cfset request.webstock = '1000'>
            </cfif>
            
          <cfquery name="rsProductsupdate"  datasource="flexifoilstore" username="" password="">
    
         
         UPDATE tbl_skus 
         SET 
         SKU_Price = '#LSCurrencyFormat(request.price, "none")#',
         SKU_WebStock = '#request.webstock#'
         
         WHERE SKU_MerchSKUID = '#request.stockcode#'
         
         </cfquery>
         Updated - #request.stockcode#, #request.webstock#, #LSCurrencyFormat(request.price, "none")#
         <br />
         </cfif>
         
    </cfoutput><cfset request.currentrow = 1>
    </cfloop> 
    Code (markup):
    When i run the file the text is also outputed after update as you can see, IF i put this into the query, it works perfectly. What is there that could be causing an issue? As the text i put in, is just the same output as what should be running in query dynamically.

    Please Help!
     
    Last edited: Oct 30, 2009
    vivid., Oct 30, 2009 IP
  2. vivid.

    vivid. Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ok just done a quick test, if i put in product code into the

    WHERE SKU_MerchSKUID = '#request.stockcode#'

    so looks like

    WHERE SKU_MerchSKUID = '60258'

    Works fine, just updates price & stock for last item in list. So is something to do with the stock code! Ive tried just using #listChangeDelims(listgetAt(row, 1),'','"')# but as some of the stock codes in XML file have a 0 in front and database doesn't keep it thats why i have it how it is.
     
    vivid., Oct 30, 2009 IP