I have a server side after dialog validate script on a dialog. I want to make sure that the records are written to a table before deleting them from another table. However, the following script does not work in that the records are not deleted from the cust_ord_web table after checking to see if the count of records in cust_ord is the same as that in cust_ord_web. If I run the script witout the "records count" validation, it works. Can anyone help?
Code:
ExecuteServerSideAction("Save Data::Save_cust_data") if rtc.flagRecordWasSaved then if variable_exists("Request.Variables.uuid") uuid = alltrim(Request.Variables.uuid) end if Dim cn as sql::connection Dim args as SQL::Arguments args.set("ID",e.dataSubmitted.idnum) args.set("Uuid",uuid) flag = cn.open("::Name::urbangrocery") dim sqlCommand as c sqlCommand="Select count(*) from cust_ord_web where Uuid =:Uuid" flag = cn.execute(sqlCommand,args) dim rs as sql::ResultSet rs = cn.ResultSet count1=rs.data(1) sqlCommand = "update rosterne set ID =:ID where Uuid =:Uuid" flag = cn.execute(sqlCommand,args) sqlCommand = "INSERT INTO cust_ord (uuid, new_code, ordered_quantity,weight,new_id) SELECT uuid, new_code, quantity, weight, new_id FROM cust_ord_web where Uuid=:Uuid" flag = cn.execute(sqlCommand,args) sqlCommand = "update cust_ord set new_id =:ID where Uuid =:Uuid" flag = cn.execute(sqlCommand,args) sqlCommand="Select count(*) from cust_ord where Uuid =:Uuid" flag = cn.execute(sqlCommand,args) dim rs as sql::ResultSet rs = cn.ResultSet count2=rs.data(1) if val(count1) = val(count2)then sqlCommand="DELETE FROM cust_ord_web WHERE Uuid =:Uuid" flag = cn.execute(sqlCommand,args) cn.close() else itemadd = "alert('Your order was not submitted; please try again or contact customer service.');" end if end if
Comment