0

我正在尝试检索数据库中的特定行,设置如下:

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)
4

1 回答 1

1

由于 LIMIT 是关键字,因此您必须引用它:

SELECT "limit" FROM Rules
于 2012-08-23T14:52:48.620 回答