两个类似的SQLite case语句,一个起作用,另一个不起作用

时间:2019-03-22 22:46:40

标签: javascript sqlite case

第一个语句有效,第二个语句返回并显示以下错误。奇怪的是,除了变量名之外,它们是相同的语句,因此,如果一个起作用,则另一个也应该起作用。

    apply plugin: 'kotlin-kapt'

buildscript {
    ext.kotlin_version = '1.3.21'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

RAF60是我的数据。我以为我可能在错误的地方加了一个引号,因为它试图以列的形式读取我的数据,但看不到它,还在我可能已将我的数据与表达式交换的某个地方寻找,但也看不到。

RFID1,2,3和CarPlates1,2,3设置为文本格式

请完全按照下面的说明陈述。

"Error: SQLITE_ERROR: no such column: RAF60"  

下面来自Node-Red的输出,我将其重新格式化以使其易于阅读。它表明数据正在填充正确的字段,并且此代码有效。在上面的语句中,插入了数据,就在发送到SQLite之前

主题:

msg.topic = 'SELECT "RFID1", "RFID2", "RFID3", case when "RFID1" = ' + readrfid + ' then RFID1 when "RFID2" = ' + readrfid + ' then RFID2 when "RFID3" = ' + readrfid + ' then RFID3  else null end dbrfid FROM SiteDB'

陈述二,sql查询与下面显示的完全一样

"SELECT "RFID1", "RFID2", "RFID3", case 
when "RFID1" = 149544749819338 then RFID1 
when "RFID2" = 149544749819338 then RFID2 
when "RFID3" = 149544749819338 then RFID3 
else null 
end dbrfid FROM SiteDB"

payload: "149544749819338"    

_msgid: "232263a1.02d34c"

_event: "node:ad044b82.8c419

0: object

下面来自Node-Red的输出,我将其重新格式化以使其易于阅读。它还显示数据正在填充正确的字段,但返回一条错误消息,下面的语句是将数据发送到SQLite之前的数据

msg.topic = 'SELECT "CarPlate1", "CarPlate2", "CarPlate3", "dbcarplate", case when "CarPlate1" = ' + readlpr + ' then CarPlate1 when "CarPlate2" = ' + readlpr + ' then CarPlate2 when "CarPlate3" = ' + readlpr + ' then CarPlate3  else null end dbcarplate FROM SiteDB

它不能在SQLite中运行,并且我收到错误消息。

topic: "SELECT "CarPlate1", "CarPlate2", "CarPlate3", "dbcarplate", case 
when "CarPlate1" = RAF60 then CarPlate1 
when "CarPlate2" = RAF60 then CarPlate2 
when "CarPlate3" = RAF60 then CarPlate3 
else null 
end dbcarplate FROM SiteDB"

payload: " RAF60 "            

_msgid: "f2831f05.42c24"

_event: "node:61abb27f.bc684c"  

0 个答案:

没有答案