我的案例陈述中出现ORA-00939: too many arguments for function
错误。
我尝试将其拆分为多个CASE
语句,但仍会出现相同的错误。
CASE WHEN l.fridge_door_modela_id = 'II-SH' THEN 'IW'
WHEN l.fridge_door_modela_id = 'IIC-SH' THEN 'IW'
WHEN l.fridge_door_modela_id = 'CD' THEN 'RPFX'
WHEN l.fridge_door_modela_id LIKE 'EXCR%' THEN SUBSTR(fridge_door_modela_id, 0, INSTR(fridge_door_modela_id, 'EXCR'),1)
WHEN l.fridge_door_modela_id LIKE 'EX%' THEN SUBSTR(fridge_door_modela_id, 0, INSTR(fridge_door_modela_id, 'EX'),1)
WHEN l.fridge_door_modela_id LIKE '%-%' THEN SUBSTR(fridge_door_modela_id, 0, INSTR(fridge_door_modela_id, '-'),1)
ELSE 'CHECK CODE'
END AS Division
答案 0 :(得分:1)
SUBSTR(fridge_door_modela_id,0,INSTR(fridge_door_modela_id,'EXCR'),1)
SUBSTR 的上述语法不正确。正确的语法是:
SUBSTR( string, start_position [, length ] )
此外,substr
的索引从1
而非0
开始。
在 SQL * Plus 中执行此操作会清楚地显示确切的错误,请参阅以下错误:
SQL> WITH DATA AS(
2 SELECT 'abcdEXCRijkl' fridge_door_modela_id FROM dual
3 )
4 SELECT SUBSTR(fridge_door_modela_id, 0, INSTR(fridge_door_modela_id, 'EXCR'),1)
5 FROM DATA;
SELECT SUBSTR(fridge_door_modela_id, 0, INSTR(fridge_door_modela_id, 'EXCR'),1)
*
ERROR at line 4:
ORA-00939: too many arguments for function
SQL>
使用正确的语法:
SQL> WITH DATA AS(
2 SELECT 'abcdEXCRijkl' fridge_door_modela_id FROM dual
3 )
4 SELECT SUBSTR(fridge_door_modela_id, 1, INSTR(fridge_door_modela_id, 'EXCR', 1, 1)-1)
5 FROM DATA;
SUBS
----
abcd
SQL>