I have an Xbasic function in a UX component that writes a record to a table using SQL INSERT. What I can't figure out is this...
For example. The COST field is a decimal(15,2) field. If I leave the field blank, the script will not write anything. If I put a number in it, it works fine and writes the record. Same goes for anything with the numeric or decimal field type. (using numeric from this point on).
Why is that?
Here's the script.
AND... see the image attached. I get the squiggly red line under end function with this warning message. Script works just fine except for the numeric/decimal fields when blank.
GRAPHICS-0016.png
For example. The COST field is a decimal(15,2) field. If I leave the field blank, the script will not write anything. If I put a number in it, it works fine and writes the record. Same goes for anything with the numeric or decimal field type. (using numeric from this point on).
Why is that?
Here's the script.
Code:
function checkinv as c (e as p) 'debug(1) dim cn as sql::Connection dim result as l = .f. dim args as sql::Arguments dim rs as sql::ResultSet dim sqlstm as c dim sku as n dim location as n dim timeadded as t dim dateadded as d dim store as c dim isDelete as l dim Inventory as l location = "1001" isBarcode = "1" timeadded = now() dateadded = date() store = "102" isDelete = "0" Inventory = "1" result = cn.open("::Name::SQL") if result then sqlstm = "SELECT MAX(SKU) FROM Inventory_NEW WHERE isBarcode = :isBarcode" args.Set("loc",location) args.Set("isBarcode",isBarcode) result = cn.execute(sqlstm,args) if result then rs = cn.ResultSet sku = rs.data(1) sku = sku+1 e._set.skuresult.value = sku sqlTruncateStatement = "TRUNCATE table Inventory_TEMP" cn.Execute(sqlTruncateStatement) sqlInsertStatement = "INSERT into Inventory_TEMP (Quantity,SKU) values (:qty, :BarCodeValue)" args.Set("BarCodeValue",sku) for i = 1 to val(e.dataSubmitted.copies) args.Set("qty",i) cn.Execute(sqlInsertStatement,args) next i args.set("NEWUSED",e.dataSubmitted.NEWUSED) args.set("CATEGORY",e.dataSubmitted.CATEGORY) args.set("ITEM",e.dataSubmitted.ITEM) args.set("MODEL",e.dataSubmitted.VENDORMODEL) args.set("SIZE",e.dataSubmitted.SIZE) args.set("PRICE",e.dataSubmitted.PRICE) args.set("ACTIVE",e.dataSubmitted.ACTIVE) args.set("DATEADDED",dateadded) args.set("TIMEADDED",timeadded) args.set("QUANTITY",e.dataSubmitted.QUANTITY) args.set("ISBARCODE",isBarcode) args.set("SKURESULT",sku) args.set("TAX1",e.dataSubmitted.TAX1) args.set("ADDITIONALINFO",e.dataSubmitted.ADDITIONALINFO) args.set("STOREGEN",store) args.set("COPIES",e.dataSubmitted.COPIES) args.set("TAXEXEMPT",e.dataSubmitted.TAXEXEMPT) args.set("INVENTORY",e.dataSubmitted.INVENTORY) args.set("SIZE_GROUP",e.dataSubmitted.SIZE_GROUP) args.set("SUPPLIER",e.dataSubmitted.SUPPLIER) args.set("MANUFACTURER",e.dataSubmitted.MANUFACTURER) args.set("DESCRIPTION",e.dataSubmitted.DESCRIPTION) args.set("LOCATION",e.dataSubmitted.LOCATION) args.set("REORDERLEVEL",e.dataSubmitted.REORDERLEVEL) args.set("FINANCEPRICE",e.dataSubmitted.FINANCEPRICE) args.set("COST",e.dataSubmitted.COST) args.set("PRICEMULTIPLE",e.dataSubmitted.PRICEMULTIPLE) args.set("FINANCEMULTIPLE",e.dataSubmitted.FINANCEMULTIPLE) args.set("PRODUCTID",e.dataSubmitted.PRODUCTID) args.set("PRICESHEETHEADER",e.dataSubmitted.PRICESHEETHEADER) args.set("PRICESHEETDESCRIPTION",e.dataSubmitted.PRICESHEETDESCRIPTION) args.set("PRODUCTVARIABLE",e.dataSubmitted.PRODUCTVARIABLE) dim sqlInsertInventory as c sqlInsertInventory = "INSERT INTO Inventory_New (new_used, category, item_name, Size, price, Active, DateAdded, TimeAdded, quantity, isBarcode, SKU, tax1, additionalinfo, StoreGen, Copies, TaxExempt, cost, VendorModel, Inventory, Size_Group, supplier, manufacturer, description, location, reorderlevel, FinancePrice,PriceMultiple, FinanceMultiple, ProductID, ProductVariable, PriceSheetHeader, PriceSheetDescription) VALUES (:NEWUSED, :CATEGORY, :ITEM, :SIZE, :PRICE, :ACTIVE, :DATEADDED, :TIMEADDED, :QUANTITY, :ISBARCODE, :SKURESULT, :TAX1, :ADDITIONALINFO, :STOREGEN, :COPIES, :TAXEXEMPT, :COST, :MODEL, :INVENTORY, :SIZE_GROUP, :SUPPLIER, :MANUFACTURER, :DESCRIPTION, :LOCATION, :REORDERLEVEL, :FINANCEPRICE, :PRICEMULTIPLE, :FINANCEMULTIPLE, :PRODUCTID, :PRODUCTVARIABLE, :PRICESHEETHEADER, :PRICESHEETDESCRIPTION )" cn.Execute(sqlInsertInventory,args) end if cn.close() end if end function
AND... see the image attached. I get the squiggly red line under end function with this warning message. Script works just fine except for the numeric/decimal fields when blank.
GRAPHICS-0016.png
Comment