0

I am trying to migrate such a simple MySQL query to Oracle SQL using PLSQL

UPDATE submaterial SET `Name` = '{$name}'".($image !== null ? ", `Picture` = '{$image}'" : "")." WHERE SubmaterialID = {$id};

When I migrate to PLSQL I get something like this

UPDATE submaterial SET Name = p_name 
     CASE WHEN p_image != NULL THEN 
       Picture = p_image
     WHERE SubmaterialID = p_Id;

When I want to execute this I get error

Error(408,6): PL/SQL: ORA-00933: SQL command not properly ended

I try also something like this but also get same error message

 UPDATE submaterial SET Name = p_name 
     CASE WHEN  p_image IS NOT NULL THEN
       Picture = p_image
     WHERE SubmaterialID = p_Id;

Does anyone know where did I made mistake ? How to write this king of query to Oracle SQL ?

1 Answer 1

1

That would be

UPDATE submaterial
   SET Name = p_name,
       picture = CASE WHEN p_image IS NOT NULL THEN p_image END
 WHERE SubmaterialID = p_Id;

i.e. you have to take picture = out of case expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.