我有一个要求,我应该从用户那里获取3个动态值,并根据它的匹配与存在的值列表进行比较,我需要使用case语句将条件添加到where子句中。 / p>
var privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" + "MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QFNUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQABAoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiAQWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOKkqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUgf1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogcmSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEAgIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmWG6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA==" + "\n-----END RSA PRIVATE KEY-----"
var publicKey = "-----BEGIN PUBLIC KEY-----\n" + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QFNUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB" + "-----END PUBLIC KEY-----"
func main() {
privKey := parse(privateKey);
pubKey := parse(publicKey);
}
答案 0 :(得分:1)
CASE
可以在WHERE
中使用,但是-语法应该可以。你不是。
这是一个显示如何的示例(另外,请注意,我为date_closed
使用了日期文字;您将其与字符串进行了比较。
select *
from my_dbsource
where 1=1
and lp_where_rep = case when :lp = 'LIFESHEILD' and :m = 'AP' and :status = 'Processed' then 'P'
when manual_flag = 'P' then 'X'
else 'Y'
end
and data_source in ('LIFESHIELD')
and date_closed >= date '2019-07-15'
and date_closed <= date '2019-07-16'
答案 1 :(得分:0)
如果您想在WHERE
子句中使用大小写,则可以使用以下内容:
AND (CASE WHEN :LP = 'LIFESHEILD' AND :M = 'AP' AND :STATUS = 'Processed' THEN flag ELSE 'P' END) = 'P'
AND (CASE WHEN :LP = 'LIFESHEILD' AND :M = 'AP' AND :STATUS = 'Processed' THEN Manual_FLAG ELSE 'P' END) = 'P'
干杯!