Link to home
Start Free TrialLog in
Avatar of Wilder1626
Wilder1626Flag for Canada

asked on

SQL where clause if statement

Hello all

I'm trying to do an IF statement but i have an error: ORA-00933: SQL command not properly ended

What i'm trying to do is if  L.ID like '0801%' it will put the word GOOD in the L.NOTES column.
If it is not like '0801%', it will put the word BAD in the L.NOTES column.

How can i do that?

Thanks again

SELECT L.ID, L.NOTES
FROM LOCATION L
WHERE ID LIKE '0800%'
CASE
    WHEN L.ID LIKE '0800%' THEN
    IF L.ID LIKE '0801%' THEN
    L.NOTES := .GOOD;
    ELSE
    L.NOTES := .BAD;
 END;
END CASE;

Open in new window

SOLUTION
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wilder1626

ASKER

Hi buttersk

If i do this:
SELECT 
    L.ID, 
    L.NOTES
FROM 
    LOCATION L
WHERE 
    ID LIKE '0800%'
CASE
    WHEN L.ID LIKE '0800%' THEN
    IF L.ID LIKE '0801%' THEN
    L.NOTES := .GOOD;
    ELSE
    L.NOTES := .BAD;
    END IF;
END CASE;

Open in new window


Now i have : ORA-00933: SQL command not properly ended
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

This is great. Thanks again