sql server - For single insert Operation some Record inserting twice -
i have created 1 method insert_detail
, in method 1 time insert operation perform each table based on condition record insert twice , make duplication in database , issue came 1 week only. please me find solution that.
private sub insert_detail(mservice_order_no, mprod_code, malt_prod_code, mqty, mtype, mfrom_original_hub, maxno) on error goto errtrap dim mcmt string dim strsql$ if mfrom_original_hub = "true" mcmt = "y" else mcmt = "n" end if strsql = "" if mtype = "a" strsql = "insert service_order_alt_parts(fk_num_service_ord_no,fk_var_orig_prod_code," & _ "fk_var_alt_prod_code,num_alt_prod_qty,num_flag,commited,from_cpl) " & _ "values('" & mservice_order_no & "','" & mprod_code & "','" & malt_prod_code & "'," & _ mqty & "," & maxno & ",'" & mcmt & "','true')" elseif mtype = "r" strsql = "insert service_order_repl_parts(fk_num_service_ord_no,fk_var_orig_prod_code," & _ "fk_var_repl_prod_code,num_repl_prod_qty,num_flag,commited,from_cpl) " & _ "values('" & mservice_order_no & "','" & mprod_code & "','" & malt_prod_code & "'," & _ mqty & "," & maxno & ",'" & mcmt & "','true')" end if if strsql <> "" conn.execute strsql errtrap: if err if err.number <> 5555 _ call writetocommonlog("insert_detail", err.number & ": " & err.description & " - " & strsql) err.raise 55555, , "" end if end sub
and calling insert_detail in:-
if mstock_found = true search_for_alternate_parts_from_cpl = 1 maxno = get_max_no(mservice_order_no, mprod_code, "a") = 1 alt_collection.count call add_parts_to_collection(alt_collection.item(i), "a", alt_qty_collection.item(i)) call insert_detail(mservice_order_no, mprod_code, alt_collection.item(i), alt_qty_collection.item(i), "a", mfrom_original_hub, maxno) call writetodebuglog("search_for_alternate_parts_from_cpl -> stockfound", mservice_order_no & " : " & mprod_code & " : (a)" & alt_collection.item(i) & " : " & alt_qty_collection.item(i) & " : " & mfrom_original_hub) if mfrom_original_hub = "true" str3 = "update product (rowlock) set commited=commited + " & cint(alt_qty_collection.item(i)) & " productcode='" & alt_collection.item(i) & "' , whseid='" & mwhseid & "'" conn.execute (str3) end if next if mfrom_original_hub = "true" str3 = "update service_order_detail (rowlock) set chr_ignore='y' fk_num_service_ord_no='" & mservice_order_no & "' , fk_var_orig_prod_code='" & mprod_code & "' " conn.execute (str3) str3 = "update service_order_alt_parts (rowlock) set chr_ignore='y' fk_num_service_ord_no='" & mservice_order_no & "' , fk_var_orig_prod_code='" & mprod_code & "' , num_flag <>" & maxno conn.execute (str3) end if set alt_collection = nothing set alt_qty_collection = nothing else set alt_collection = nothing set alt_qty_collection = nothing search_for_alternate_parts_from_cpl = 0 end if
Comments
Post a Comment