Hello CF'ers... I have a page that inserts twice sometimes and does it correct (insert only once) every once in a while. I am absolutely clueless as to why. The page does have a few loops but on of the inserts is not in one and it still inserts twice. I put tests info on the screen to show me where it is and what it is doing, and it showed that it only ran the query one for each record.
Here is the code..(Access 2000 DB, Windows 2000 server, CF 5) <cfif myorder is 0> <cfoutput>How many times do I insert into Order plus myorder is #myorder#<br></cfoutput> <cfquery name="ins_first_ord" datasource="#dsn#" dbtype="ODBC">insert into order_tbl(order_cust,order_date,order_tax, order_shipping, order_total, order_comment, order_payment) values(#seslogin#,'#dt#',#form.thetax#, #form.theship#, #form.grand_total#, '#form.comments#', #form.payment#)</cfquery> <cfoutput>Show me query 1 for order<br> insert into order_tbl(order_cust,order_date,order_tax, order_shipping, order_total, order_comment, order_payment) values(#seslogin#,'#dt#',#form.thetax#, #form.theship#, #form.grand_total#, '#form.comments#', #form.payment#)<br></cfoutput> <!---get the key from the order record---> <cfquery name="get_ord_key" datasource="#dsn#" dbtype="ODBC">select max(order_key) as orderkey from order_tbl where order_cust = #seslogin# and order_date = ###dt###</cfquery> <!---insert into cart_tbl---> <cfset myorder = 1> </cfif> <cfloop index="item" from="1" to="#cntr#"> <cfoutput>How many times do I insert into Cart plus item is #item#<br></cfoutput> <cfquery name="ins_cart" datasource="#dsn#" dbtype="ODBC">insert into cart_tbl(cart_item,cart_qty,cart_price,cart_cust,cart_order,cart_date) values(#thecart[item][5]#, #thecart[item][4]#, #replace(thecart[item][3], "$", "", "ALL")#, #seslogin#, #get_ord_key.orderkey#, '#dt#')</cfquery> <cfoutput>Show me the queries for the cart<br> insert into cart_tbl(cart_item,cart_qty,cart_price,cart_cust,cart_order,cart_date) values(#thecart[item][5]#, #thecart[item][4]#, #replace(thecart[item][3], "$", "", "ALL")#, #seslogin#, #get_ord_key.orderkey#, '#dt#')<br></cfoutput> <!---clear inventory from item tbl---> <cfquery name="get_the_qty" datasource="#dsn#" dbtype="ODBC">select item_qty_avail from item_tbl where item_key = #thecart[item][5]#</cfquery> <cfset new_qty = get_the_qty.item_qty_avail - thecart[item][4]> <cfif get_the_qty.item_qty_avail is not 0> <cfquery name="del_from_item" datasource="#dsn#" dbtype="ODBC">update item_tbl set item_qty_avail = #new_qty# where item_key = #thecart[item][5]#</cfquery> </cfif> </cfloop> Here is the output.... How many times do I insert into Order plus myorder is 0 Show me query 1 for order insert into order_tbl(order_cust,order_date,order_tax, order_shipping, order_total, order_comment, order_payment) values(4,'12/04/02',19.60, 20.00, 284.5352, 'None', 1) How many times do I insert into Cart plus item is 1 Show me the queries for the cart insert into cart_tbl(cart_item,cart_qty,cart_price,cart_cust,cart_order,cart_date) values(2, 1, 132.99, 4, 1, '12/04/02') How many times do I insert into Cart plus item is 2 Show me the queries for the cart insert into cart_tbl(cart_item,cart_qty,cart_price,cart_cust,cart_order,cart_date) values(1, 1, 99.95, 4, 1, '12/04/02') How many times do I insert into Cart plus item is 3 Show me the queries for the cart insert into cart_tbl(cart_item,cart_qty,cart_price,cart_cust,cart_order,cart_date) values(5, 1, 12.00, 4, 1, '12/04/02') Does anyone have any ideas? Thanks Brian Yager President - North AL Cold Fusion Users Group http://www.nacfug.com Sr. Systems Analyst Sverdrup/CIC [EMAIL PROTECTED] (256) 842-8342 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com