I need to update a table based on another table, so I have the statement:

update FAULTS
set FAULTS.FAULT_STATE = (
    select INCIDENTS.TICKET_STATE from INCIDENTS
    where INCIDENTS.CF_ID = FAULTS.CF_ID
)


And it gives me error saying: 

ORA-01427: single-row subquery returns more than one row


I tried DISTINCT but the state values are different too so DISTINCT does not work. So I changed it too:

update FAULTS
set FAULTS.FAULT_STATE = (
    select INCIDENTS.TICKET_STATE from INCIDENTS
    where INCIDENTS.CF_ID = FAULTS.CF_ID and rownum = 1
)


Now it does not give errors. 

The problem is, if the sub-query returns a null, it will also update the row and clear the content. Any fix for that?


Question: Is it reasonable to use Javascript MVC Frameworks for closed source paid web applications?
Answer: If you are only using REST as your entire backend to communicate with the database, that maybe your problem. Using EJB and JPA, the business logic is abstracted away from the user, and handled by the server and its database. 

If your application logic is happening in your java code, well then I would suggest that it is not clean code. A servers job is to respond to the questions asked by the client. If the business application logic happens in javascript, then the client is essentially answering their own questions. Essentially, your questions makes no sense.