Refresh query if instruction for Oracle

I need to update a newly created column in my oracle table. To do this, I need to use the existing values ​​in the row to decide how to fill this column, I get an error:

java.lang.NullPointerException -> See Debug Output for details 

This is my request:

 UPDATE SCHEMA_NAME.TABLE_NAME SET OCO= IF CO= 'Y' AND COM='Y' THEN { 'Y' } ELSE { 'N' } END IF; 

Any syntax suggestions?

+6
source share
1 answer

You can use the CASE expression in the SET clause.

For instance,

 UPDATE table SET schema.column = CASE WHEN CO= 'Y' AND COM='Y' THEN 'Y' ELSE 'N' END 
+13
source

Source: https://habr.com/ru/post/982671/


All Articles