Note that there are some explanatory texts on larger screens.

plurals
  1. PODB Error=ORA-01407: cannot update ("XXX"."XXX"."VALUE") to NULL.
    primarykey
    data
    text
    <p>I have (simplified for this question) a table 'TAB' with two columns 'id' (integer and not null in db) and 'value' (varchar and not null in db). I am using a java application to update 'value' column for multiple rows in one go (which is my requirement). I have used update statement with case and when keyword. The query is being generated at runtime depending on number of rows modified. </p> <p>The query works fine if data is updated for all rows together, but it gives me error when updated for less rows. Say we have three rows with id = 1, 2 and 3 with values A ,B and C resp.<br> When the query is fired for all three rows together then it works fine </p> <pre><code>UPDATE TAB set value = CASE WHEN id = 1 THEN 'X' WHEN id = 2 THEN 'Y' WHEN id = 3 THEN 'Z' END </code></pre> <p>But when the query is fired for less than three rows then I am encountering with a DB error. </p> <pre><code>UPDATE TAB set value = CASE WHEN id = 1 THEN 'X' END </code></pre> <p>Results in following error:</p> <blockquote> <p>DB Error=ORA-01407: cannot update ("XXX"."XXX"."VALUE") to NULL.</p> </blockquote> <p>I know this is happening because the 'value' column is not null in DB. I want to know whether the above query is trying to update all the remaining values with NULL? </p> <p>The query works fine if I add ELSE part as written below.</p> <pre><code>UPDATE TAB set value = CASE WHEN id = 1 THEN 'X' ELSE TAB.value END </code></pre> <p>Will the above query impact any performance issue, if there are multiple rows in DB.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload