I’ve writing an app which, when given a couple of params calculates the ingredients and ingredient amounts required to make a cake.
So, I’ve got a sqlite query which interrogates the DB and returns the result in a column called theCost. When run against the DB the ‘raw’ query looks like this:
SELECT (basics.amount_gms * (SELECT (cost.costPerUnit_gms / cost.amtPerUnit_gms) FROM cost WHERE cost.ingredientId=12 and basics.cakeSizeId=1) ) as cost from basics where basics.cakeSizeId=1 and basics.ingredientId=12
It returns the correct result every time.
In my Lua script I have the code below, which does the same thing as the query above. The only difference is the params are inserted dynamically.
However, whatever goes into the query, the result is always 0.9, which is wrong, and irritating…
Can anyone help me out with why it might be doing this? I know I’m iterating over a sqlite result that only has one columns and one value in it, surfing for an easier way, this was the easiest I could find, so is there something peculiar with the way the column result is being returned…?
Ta
MrC
query1 = “SELECT (basics.amount_gms * (SELECT (cost.costPerUnit_gms / cost.amtPerUnit_gms) FROM cost WHERE cost.ingredientId=12 and basics.cakeSizeId=”…paramCakeSize…") ) as theCost from basics, cost where basics.cakeSizeId="…paramCakeSize…" and basics.ingredientId=12"
local sugarPasteVal
for row in _G.sqliteDB:nrows( query1 ) do
sugarPasteVal = row.theCost
end [import]uid: 45444 topic_id: 31117 reply_id: 331117[/import]
also tracked and traced everything in sight and still getting 0.9 as a result. Either I’ve done something so fundamentally wrong I can’t see it, or the Lua Gods are punishing me… [import]uid: 45444 topic_id: 31117 reply_id: 124493[/import]