更新 Oracle 中的多个列

Updating multiple columns in Oracle

如果我尝试将 (, CCY_TO_BASE_RATE = EXCHANGERATE.MID_RATE) 添加到更新语句中,它会显示以下错误。

ORA-06550: line 8, column 21:
PL/SQL: ORA-00923: FROM keyword not found where expected

ORA-06550: line 6, column 1:
PL/SQL: SQL Statement ignored

然而,如果没有 (, CCY_TO_BASE_RATE = EXCHANGERATE.MID_RATE),该声明是有效的。 那么我需要如何编辑我的代码才能使声明有效?

DECLARE
    v_system_base_ccy NVARCHAR2(10);
BEGIN
    v_system_base_ccy := dbo.Fn_parameter('SYSTEMBASECCY');

    UPDATE tbl_dvcollateral A
    SET    coll_value_base = (SELECT coll_value * Nvl(EXCHANGERATE.mid_rate, 1),
                                     ccy_to_base_rate = EXCHANGERATE.mid_rate
                              FROM   (SELECT mid_rate,
                                             from_ccy
                                      FROM   TABLE(
                                     dbo.Fn_exchangeratetable(:V_AS_OF_DATE,
                                     NULL,
                                     v_system_base_ccy) )
                                     )EXCHANGERATE
                              WHERE  A.ccy = EXCHANGERATE.from_ccy(+)),
           last_updated_by = :V_LOGIN_ID,
           last_updated_datetime = To_timestamp(To_char(systimestamp,
                                                'YYYY-MM-DD HH24:MI:SS'),
                                   'YYYY-MM-DD HH24:MI:SS')
    WHERE  as_of_date = :V_AS_OF_DATE
           AND record_status_id = :V_AUTHORIZED;
END; 

我可能误解了你在做什么,但你的目标列似乎在更新语句的错误一侧:

UPDATE tbl_dvcollateral A
SET    (coll_value_base, ccy_to_base_rate) =
                         (SELECT coll_value * Nvl(EXCHANGERATE.mid_rate, 1),
                                 EXCHANGERATE.mid_rate
                          FROM   (SELECT mid_rate,
...

在第 8 行你有

ccy_to_base_rate = EXCHANGERATE.mid_rate

作为 select 表达式。从技术上讲,这是 Oracle SQL 不允许的布尔值。 您需要删除此表达式。我不知道你需要用什么来替换它,因为我不知道你试图制定什么。