-1

当用户搜索没有Hamza (ء)的احمد时,我试图进行查询,它返回的结果和结果如下:hamzamhamza

select * 
  from EMPLOYEES  
 Where (Replace(Replace(Replace(first_name, 'ا', 'أ'), 'و','ؤ'), 'ي', 'ى') 
        like (Replace(Replace(Replace(['احمد'], 'ا', 'أ'), 'و','ؤ'),'ى','ي')

但我得到了例外:Oracle error - ORA-00936: missing expression

请告知如何解决它。

4

2 回答 2

1

您错过了 2 个括号:

SELECT * 
  FROM EMPLOYEES  
 WHERE (REPLACE(REPLACE(REPLACE(first_name, 'ا', 'أ'), 'و','ؤ'), 'ي', 'ى'))
        LIKE (REPLACE(REPLACE(REPLACE(['احمد'], 'ا', 'أ'), 'و','ؤ'),'ى','ي'))
于 2013-07-08T09:26:27.417 回答
0

ORA-00936: missing expression always indicates a syntax error. There are several bloomers in your posted code.

  1. The number of ) must match the number of (.
  2. [ is not a recognised character in Oracle SQL. It's not clear what you're trying to achieve with them, so it's difficult to know how to suggest you fix this, but you need to get rid of them somehow.
  3. The ,( construct is wrong.

Or rather apparent bloomers. Because when I attempted to correct your code the editor reversed my changes e.g. ) turned back to (. When I pasted it into an ASCII editor I saw this ...

Replace(Replace(Replace(first_name, '?', '?'), '?','?'), '?', '?') 

... which gives the correct count of ) and the correct nesting of REPLACE() calls.

Hypothesis: some kind of character set mistranslation. So the question is, is the SO editor introducing this corruption or are you experiencing this in your client too?

Incidentally the right side of the operation in ASCII is

REPLACE(REPLACE(REPLACE(['????'], '?', '?'), '?','?'),'?','?'))

So those rogue [ ] are real (I think) and you must remove them. Given that the other "errors" may just be artefacts of the SO Editor I think those square brackets are the thing you should focus on.

于 2013-07-08T13:41:24.827 回答