script for copying a column to another column of different table

SQL command not properly ended - error is showing while I run below code. I want to copy all values from Process column of table T_DOC to Process column of T_CHARACTERISTICS. Now Process column in T_CHARACTERISTICS is NULL. (Except this column all other columns of T_CHARACTERISTICS is having values) Thanks in advance

UPDATE T_CHARACTERISTICS 
SET T_CHARACTERISTICS.PROCESS = T_DOC.PROCESS
FROM T_CHARACTERISTICS  
JOIN  T_DOC ON T_CHARACTERISTICS.ID = T_DOC.ID

2 answers

  • answered 2017-12-06 01:40 Tim Biegeleisen

    Oracle does not support update joins, but we can use a correlated subquery instead:

    UPDATE T_CHARACTERISTICS t1
    SET PROCESS = (SELECT t2.PROCESS FROM T_DOC t2 WHERE t2.ID = t1.ID);
    

  • answered 2017-12-06 01:40 Gordon Linoff

    This is not proper Oracle syntax. Here is one method:

    UPDATE T_CHARACTERISTICS c
        SET PROCESS = (SELECT d.PROCESS
                       FROM T_DOC d
                       WHERE c.ID = d.ID
                      )
        WHERE EXISTS (SELECT 1
                      FROM T_DOC d
                      WHERE c.ID = d.ID
                     );