user1375026
user1375026

Reputation: 413

PL/SQL Cursor ORA-00936 Missing Expression

Can anyone help me out with this:

CURSOR csr(start IN NUMBER, finish IN NUMBER, sort IN VARCHAR2, search IN VARCHAR2) IS
  SELECT id, text, code, name
    FROM (SELECT rownum r,
                 id,
                 text,
                 table1.code,
                 name 
            FROM table1, table2
       WHERE table1.code = table2.code
             AND (id LIKE ||'%'||search||'%' 
              OR  name LIKE ||'%'||search||'%'
              OR  table1.code LIKE ||'%'||search||'%'
              OR  text   LIKE ||'%'||search||'%')
          )
   WHERE   r > start
 AND     r <= finish
   ORDER BY sort;

This is giving me the *ORA-00936 Missing Expression error on the following line:

AND( id LIKE ||'%'||search||'%'*

I'm only testing the code but can't find what the problem is.

Any help appreciated.

Upvotes: 0

Views: 2158

Answers (1)

schtever
schtever

Reputation: 3250

The concatenation operator "||" goes BETWEEN the operands. It's an error to put one before the first term. So "id LIKE ||'%'||search||'%'" should be "id LIKE '%'||search||'%'"

Upvotes: 1

Related Questions