Refresh all rows of one column

I am dealing with two tables that have 2 columns as follows.

Table 1: table_snapshot account_no | balance_due

Table 2: table_ paid account_no | post_balance | delta_balance

I added a third column to table2 with the following command:

ALTER TABLE table_paid ADD delta_balance number(18);

I am trying to use the following query to update a new column (delta_balance) with a difference in balances between 1 and 2. FYI, table_paid is a subset of table_snapshot. i, e., table 2 contains only a few accounts, presented in table 1. I get an error: SQL Statement was not completed. I am using the following query:

UPDATE table_paid
SET table_paid.delta_balance = table_paid.post_balance - table_snapshot.balance_due
from table_paid, table_snapshot
WHERE table_paid.account_no = table_snapshot.account_no;

Appreciate if someone can fix my request.

Many thanks.

novice.

+3
3

Oracle UPDATE... FROM, MS Sql Server (, , ANSI ). , , Oracle , , :

  UPDATE ( SELECT tp.delta_balance
                , tp.post_balance
                , ts.balance_due
             FROM table_paid tp
                  JOIN table_snapshot ts
                    ON tp.account_no = ts.account_no
         )
     SET delta_balance = post_balance - balance_due;

"", , Babar palindrom, table_paid, table_snapshot . 1-1, , .

, , ( ) , account_no ( "table_account" ). , , 1-1 - 15K , .

: table_snapshot , table_paid, table_snapshot table_paid . , - table_paid, ; , post_balance - balance_due -?

, - , : "ORA-01779: , , ". ( ), , . 1-1 , . Oracle : " ".

( ORA-01427: ), , ; , , .

, , account_no table_snapshot. table_paid .

+4

 UPDATE table_paid
 SET table_paid.delta_balance = table_paid.post_balance - 
 (SELECT table_snapshot.balance_due from table_snapshot WHERE table_paid.account_no = 
 table_snapshot.account_no);
+4

UPDATE table_paid SET table_paid.delta_balance = table_paid.post_balance - ( balance_due table_snapshot WHERE table_paid.account_no = table_snapshot.account_no)

+1

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


All Articles