IF LENGTH(tmp_char)>1 THEN SELECT ELT(INTERVAL(CONV(HEX(tmp_char),16,10),0xB0A1,0xB0C5,0xB2C1,0xB4EE,0xB6EA,0xB7A2,0xB8C1,0xB9FE,0xBBF7,0xBFA6,0xC0AC ,0xC2E8,0xC4C3,0xC5B6,0xC5BE,0xC6DA,0xC8BB,0xC8F6,0xCBFA,0xCDDA ,0xCEF4,0xD1B9,0xD4D1), 'A','B','C','D','E','F','G','H','J','K','L','M','N','O','P','Q','R','S','T','W','X','Y','Z') INTO tmp_cc; 如何转换成postgresql的sql语句
时间: 2023-08-20 20:05:55 浏览: 1109
ELT232DL_V10使用说明书(最终修订版)1
在 PostgreSQL 中,你可以使用 `CASE` 表达式来实现类似的逻辑。下面是将给定的 SQL 代码转换为 PostgreSQL 的 SQL 语句的示例:
```sql
SELECT
CASE
WHEN LENGTH(tmp_char) > 1 THEN
CASE
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 45281 AND 45285 THEN 'A'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 45457 AND 45458 THEN 'B'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 45729 AND 45755 THEN 'C'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 46062 AND 46090 THEN 'D'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 46346 AND 46378 THEN 'E'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 46498 AND 46530 THEN 'F'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 46657 AND 46689 THEN 'G'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 46817 AND 46845 THEN 'H'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 47103 AND 47127 THEN 'J'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 47334 AND 47358 THEN 'K'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 47468 AND 47492 THEN 'L'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 47610 AND 47638 THEN 'M'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 47809 AND 47829 THEN 'N'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 48026 AND 48052 THEN 'O'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 48162 AND 48187 THEN 'P'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 48274 AND 48300 THEN 'Q'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 48438 AND 48464 THEN 'R'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 48657 AND 48682 THEN 'S'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 48858 AND 48883 THEN 'T'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 49189 AND 49217 THEN 'W'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 49324 AND 49354 THEN 'X'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 49382 AND 49407 THEN 'Y'
WHEN CONV(HEX(tmp_char), 16, 10) BETWEEN 49655 AND 49690 THEN 'Z'
END
END AS tmp_cc;
```
请注意,我已经将 `ELT` 函数替换为了 `CASE` 表达式,并且使用了 `BETWEEN` 来检查给定的范围。你可能需要根据具体的需求对这些范围进行调整。
阅读全文