I have an Xbasic function that writes the values from a repeating section to an SQL table. It takes some from the repeating section and some from outside of it and writes to the same table.
The issue I have is this. Some of the rows in the repeating section may have a blank value for the VARPRICE field. When this is the case, the sqlInsert does not fire for that row. It ignores it due to what I can see because one of the values are blank. I still want it to write to the table so I can see the VARIABLENAME, etc.
What would I add so it writes the record regardless of whether it's blank or has a value?
Bear with my code. I'm still new to the actual Xbasic scripting.
The issue I have is this. Some of the rows in the repeating section may have a blank value for the VARPRICE field. When this is the case, the sqlInsert does not fire for that row. It ignores it due to what I can see because one of the values are blank. I still want it to write to the table so I can see the VARIABLENAME, etc.
What would I add so it writes the record regardless of whether it's blank or has a value?
Code:
function insertVariables as v (e as P) dim cn as SQL::Connection dim args as sql::arguments dim rsCount as n dim dataCount as n sqlInsert = "Insert into OrderItemsVariables (VARIABLENAME, PRODUCT_INFORMATION_ID, VARIABLEITEM, USER_COMPANY_ID, CARTLINKID, PRODUCTLINKID, VARSKU, VARPRICE) Values (:VN, :PID, :VI, :CID, :CLID, :PLID, :VSKU, :VP)" rsCount = e.repeatingSectionInfo["VARIABLES"].rowCount cn.open("::name::SQL Server") args.set("PID",e.dataSubmitted.PRODUCT_INFORMATION_ID) args.set("CID",e.dataSubmitted.USER_COMPANY_ID) args.set("CLID",e.dataSubmitted.CARTLINKID) args.set("PLID",e.dataSubmitted.PRODUCTLINKID) for i = 1 to rsCount if e.dataSubmitted.VARIABLEITEM[i] <> "" then args.set("VN",e.dataSubmitted.VARIABLENAME[i]) args.set("VI",e.dataSubmitted.VARIABLEITEM[i]) args.set("VSKU",e.dataSubmitted.VARSKU[i]) args.set("VP",e.dataSubmitted.VARPRICE[i]) cn.Execute(sqlInsert,args) end if next i cn.close() end function
Comment