0
我想在我的數據庫中檢索特定行,設置是這樣的:發行檢索特定的SQL行
CREATE TABLE "Rules" ("credit" BOOL NOT NULL , "debit" BOOL NOT NULL , "product_code" INTEGER, "frequency" INTEGER, "percentage" FLOAT, "limit" FLOAT, "below" BOOL, "above" BOOL, "price" FLOAT)
我的代碼是:
class Process_Rules
def initialize()
@rules = Array.new() {Array.new()}
end
def process()
db = SQLite3::Database.open "Checkout.sqlite"
#############################################
productRules = db.execute "SELECT product_code FROM Rules WHERE product_code NOT NULL"
@rules.push([])
for i in 0..productRules.length
@rules[0].push(productRules[i])
end
#############################################
limitRules = db.execute "SELECT limit FROM Rules" #ERRORSOME HERE, PREVIOUS SQL STATEMENT EXECUTES FINE
#############################################
db.close()
end
end
錯誤:
in 'initialize': near 'limit': syntax error (SQLite3::SQLException)
謝謝,我只是用limit關鍵字想出來的! – Neeta
由於查詢已在引號中,因此我需要使用單引號,而不是雙引號。 – Neeta
此外,重命名此列可能是個好主意。最好避免在列名中使用關鍵字。 –