user13435420
user13435420

Reputation: 19

oracle SQL keyword not where expected - Issue with REPLACE Operator?

I'm having an issue with my query where I'm getting an error,

ORA-00923: FROM keyword not found where expected.

However, I think the FROM statement is in the right place, and it might be one of the other operators that's causing the error to be thrown.

SELECT 
column1, column2
ORDER BY column2 DESC
REPLACE(REPLACE('%(param1)s', 'a', 'b'), 'c', 'd'),
CASE WHEN REGEXP_INSTR('%(param1)s', '\\\') > 0 AND REGEXP_LIKE(column1.'%(param1)s') THEN 'Y' END REGEXP_MATCH,
CASE WHEN REGEXP_INSTR('%(param1)s', '\\\') = 0 AND column1 LIKE '%(param1)s' THEN 'Y' END LIKE_MATCH,
FROM TABLE1
WHERE (REGEXP_INSTR('%param1)s', '[|(\\\[]') > 0 AND REGEXP_LIKE(column1.'%(param1)s')) 
OR
(REGEXP_INSTR('%param1)s', '[|(\\\[]') = 0 AND column1 LIKE ('%(param1)s') 
OR ('%(param1)s' IS NULL)

Upvotes: 0

Views: 40

Answers (1)

Littlefoot
Littlefoot

Reputation: 142713

Misplaced ORDER BY, dots instead of commas, missing closing brackets ... you should really pay more attention to what you do.

This should be OK as far as syntax is concerned. Will it do what you meant it to do, I have no idea.

  SELECT column1,
         column2,
         REPLACE (REPLACE ('%(param1)s', 'a', 'b'), 'c', 'd'),
         CASE
            WHEN     REGEXP_INSTR ('%(param1)s', '\\\') > 0
                 AND REGEXP_LIKE (column1, '%(param1)s')
            THEN
               'Y'
         END
            REGEXP_MATCH,
         CASE
            WHEN     REGEXP_INSTR ('%(param1)s', '\\\') = 0
                 AND column1 LIKE '%(param1)s'
            THEN
               'Y'
         END
            LIKE_MATCH
    FROM TABLE1
   WHERE    (    REGEXP_INSTR ('%param1)s', '[|(\\\[]') > 0
             AND REGEXP_LIKE (column1, '%(param1)s'))
         OR (       REGEXP_INSTR ('%param1)s', '[|(\\\[]') = 0
                AND column1 LIKE ('%(param1)s')
             OR ('%(param1)s' IS NULL))
ORDER BY column2 DESC

Upvotes: 2

Related Questions