Search code examples
hanahana-sql-script

Update 2 joined tables simultaneously on HANA?


Can I update 2 columns from 2 tables joined by foreign key with one statement in SAP HANA


Solution

  • No, SAP HANA up to its current version HANA 2 SPS 05 does not support multi-table updates (or inserts/deleted for that matter).

    Depending on the use-case, you may be able to emulate the behavior via SQLScript, like e.g. so:

    DO BEGIN 
       data_to_insert = SELECT id, stuff FROM DB;
    
    -- update table 1
       UPDATE tab1 t FROM t, :data_to_insert d
              SET t.one_stuff = d.stuff
              WHERE t.id = d.id;
    
    -- update table 2
       UPDATE tab2 t FROM t, :data_to_insert d
              SET t.two_stuff = d.stuff
              WHERE t.id = d.id;
    END;