Translate SQL Server code to Oracle

  • I have to translate your application with SQL Server on Oracle.

    I have 2 tables:

    create table aaa

    (

    id_a int,

    id_b int

    )

    truncate table aaa

    insert into aaa values(1,1)

    insert into aaa values(2,2)

    select * from aaa

    create table bbb

    (

    id_aa int,

    id_bb int

    )

    truncate table bbb

    insert into bbb values(1,11)

    insert into bbb values(2,22)

    select * from bbb

    I have this code:

    update a

    set a.id_b = b.id_bb

    FROM aaa a, bbb b

    WHERE a.id_a = b.id_aa

    How to translete to Oracle this code without cursor?

    https://www.youtube.com/user/learnwithtutorials/playlists

  • You can use MERGE clause:

    MERGE INTO aaa a

    USING(

    SELECT id_aa ,

    id_bb

    FROM bbb

    )e

    ON(a.id_a =e.id_aa)

    WHEN MATCHED THEN

    UPDATE SET a.id_b =e.id_bb

    select * from aaa

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply